Composite Pattern A minimalistic example. You can run it with: $ npm i $ npm run test See ./tests/composite.test.ts for the implementation.