Here you will find the 23 (Gof) design patterns implemented in Javascript using the ES6 classes. These would be real world examples using Nodejs APIs. Also I have put extra effort to make JS classes abstract.
Follows the list of patterns separed by type:
Creational patterns are ones that create objects for you, rather than having you instantiate objects directly. This gives your program more flexibility in deciding which objects need to be created for a given case.
- Abstract factory: provide an interface for creating families of related or dependent objects without specifying their concrete classes.
- Builder: separate the construction of a complex object from its representation, allowing the same construction process to create various representations.
- Factory method: define an interface for creating a single object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
- Prototype: specify the kinds of objects to create using a prototypical instance, and create new objects from the 'skeleton' of an existing object, thus boosting performance and keeping memory footprints to a minimum.
- Singleton: ensure a class has only one instance, and provide a global point of access to it.