└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # 🧩 JavaScript Patterns by Examples 2 | 3 | > Patterns for JavaScript, Node.js, and Async programming by platform native examples 4 | 5 | | Pattern | Pure JavaScript | Web API | Node.js | 6 | | ----------------------- | ---------------- | -------- | -------- | 7 | | 🏭 Creational | | | | 8 | | Abstract factory | | | | 9 | | Builder | Chaining | | stream.pipe.on, Query builder | 10 | | Factory method | | `document.createElement` | `crypto.createHash` | 11 | | Prototype | Class with private fields and `clone` method, `JSON.stringify/parse`, `structuredClone`, `Object.assign` + `Object.setPrototypeOf` | | `node:v8`, `serialize`, `deserialize` | 12 | | Singleton | IIFE, modules, `global`, `window` | esm/cjs modules | `module.exports` | 13 | | 🤝 Structural | | | | 14 | | Adapter | promisify / callbackify | `fetch` polyfill around `XMLHttpRequest` | `util.promisify` | 15 | | Bridge | | | | 16 | | Composite | Hierarchical strictures, for example goods in nested categories | DOM elements | | 17 | | Decorator | Decorator syntax, boxing, wrappers | | | 18 | | Facade | | `document.querySelector` | `http2.createSecureServer` | 19 | | Flyweight | Object pools | | Connection pools | 20 | | Proxy | Built-in `Proxy` | | `node:vm.createContext` | 21 | | ⚡ Behavioral | | | | 22 | | Chain of responsibility | | | `middleware` | 23 | | Command | | | | 24 | | Interpreter | | | | 25 | | Iterator | `Iterator`, `AsyncIterator` | Streams API | `node:stream` | 26 | | Mediator | | | | 27 | | Memento | | | | 28 | | Observer | callbacks, events | `EventTarget` | `EventEmitter` | 29 | | State | | | | 30 | | Strategy | `Map` | | Routing (end-point collections) | 31 | | Template method | | | | 32 | | Visitor | | | | 33 | --------------------------------------------------------------------------------