Adapter pattern lets you wrap an otherwise incompatible object in an adapter to make it compatible with another class.

Wikipedia says:

In software engineering, the adapter pattern is a software design pattern that allows the interface of an existing class to be used as another interface. It is often used to make existing classes work with others without modifying their source code.

Real world example

Consider that you have some pictures in your memory card and you need to transfer them to your computer. In order to transfer them you need some kind of adapter that is compatible with your computer ports so that you can attach memory card to your computer. In this case card reader is an adapter. Yet another example would be a translator translating words spoken by one person to another.

Github repo: link.

Demo example:

Power adapter: a two pronged legged US plug can’t be connected to an EU outlet, it needs to use a power adapter.

Swift

Adapter.swift

TypeScript