A singleton makes sense when it prevent multiple access to a resource than must not be accessed in that way. But sometimes a singleton design is used because it is sufficient for expected usage. But that may block expanded usage unecessarily.
ES6 dynamic import can import a singelton module into a closure allowing a singleton to become a non-singleton class. See the file yargs-class.mjs
below.
The result of test-yargs0class.mjs -
argv[0]= {
"_": [
"goo"
],
"car": "CAR",
"r": "CAR",
"caz": "CAZ",
"z": "CAZ",
"$0": "src/test-yargs-obj.mjs"
}
argv[1]= {
"_": [
"goo"
],
"car": "BAR",
"r": "BAR",
"caz": "BAZ",
"z": "BAZ",
"$0": "src/test-yargs-obj.mjs"
}