🟨 JAVASCRIPT PATTERN DIFFICULTY: Adept Structural

The Translator Adapter

Convert the interface of an ancient grimoire into another interface clients expect.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Adapter
ARCANUM SCHOOL: Divination // Linguistics
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// JAVASCRIPT IDIOMATIC PATTERN //
class ModernSpellbook {
  castSpell(spellName) {
    console.log(`Casting modern spell: ${spellName}`);
  }
}

class AncientScroll {
  chantRune(runeSequence) {
    console.log(`Chanting ancient runes: ${runeSequence}`);
  }
}

class ScrollAdapter extends ModernSpellbook {
  constructor(ancientScroll) {
    super();
    this.ancientScroll = ancientScroll;
  }

  castSpell(spellName) {
    const runeMap = {
      'Fireball': 'Ignis-Ka',
      'Heal': 'Vita-San',
    };
    const runes = runeMap[spellName] || 'Unknown-Rune';
    this.ancientScroll.chantRune(runes);
  }
}

const scroll = new AncientScroll();
const adapter = new ScrollAdapter(scroll);
adapter.castSpell('Fireball');

The Translator Adapter

When the ancient texts of power are incompatible with modern casting foci, you do not rewrite history. You build an adapter—a translation layer that channels the old magic into new forms.

Runic Tags: #translation #compatibility #ancient