A repository of common design patterns written in Typescript.
Credits:
Node and Yarn is required.
yarn install
to install dependencies- (Optional) Install Prettier VSCode extension, if you want to play around while keeping code consistency
Choose a design pattern by changing the enum in the example
variable in src/index.ts
.
enum DesignPattern {
FACTORY = 'factory',
MEMENTO = 'memento',
STATE = 'state',
ITERATOR = 'iterator',
COMPOSITE = 'composite',
BRIDGE = 'bridge',
MEDIATOR = 'mediator',
PROXY = 'proxy',
CHAIN_OF_RESPONSIBILITY = 'chain',
FLYWEIGHT = 'flyweight',
}
const example: DesignPattern = DesignPattern.FLYWEIGHT // Edit here
yarn build
to transpile Typescript to Javascriptyarn start
to run the script- (Optional)
yarn dev
to run a nodemon development server