Consider adding a factory method
See original GitHub issueI know it’s “idiomatic”, but I’ve never been a fan of this style for requiring a class that will only be instantiated once:
const Conf = require('conf');
const config = new Conf();
What about adding a factory method like this:
const conf = require('conf').new();
or even:
const conf = require('conf')();
This could be supplemental to the existing instantiation behavior.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Factory Method - Refactoring.Guru
Factory Method is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the...
Read more >Factory Method Design Pattern - SourceMaking
If you have an inheritance hierarchy that exercises polymorphism, consider adding a polymorphic creation capability by defining a static factory method in the ......
Read more >The Factory Method Pattern and Its Implementation in Python
The new design of Factory Method allows the application to introduce new features by adding new classes, as opposed to changing existing ones....
Read more >Factory method design pattern in Java - GeeksforGeeks
The factory design pattern says that define an interface ( A java interface or an abstract class) for creating object and let the...
Read more >Factory Pattern. When to use factory methods? - Stack Overflow
Factory methods should be considered as an alternative to constructors - mostly when constructors aren't expressive enough, ie.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

somewhat related: this isn’t a great first impression:
because node’s REPL has no module.parent:
(and exposing a constructor would let me feed conf what it needs)
My current environment:
Good point. Not on that 🚋 yet.