Prekladá rozhranie jednej triedy na rozhranie, ktoré klient očakáva.
// Third-party code. We cannot rewrite it — it has run in production for years.class LegacyGateway { sendPaymentXml(xml) { return '<response><status>OK</status></response>'; }} // The interface the client knows how to use.class Payment { pay(amount) { throw new Error('abstraktná metóda'); }} class GatewayAdapter extends Payment { constructor(gateway) { super(); this.gateway = gateway; } pay(amount) { const xml = '<payment><amount>' + amount + '</amount></payment>'; const response = this.gateway.sendPaymentXml(xml); return { status: response.includes('<status>OK</status>') ? 'ok' : 'error' }; }} const payment = new GatewayAdapter(new LegacyGateway());payment.pay(25); // { status: 'ok' }