Echo JS 0.11.0

<~>

joncys 1482 days ago. link 2 points
This brings in a lot of unnecessary clutter that is needed to create singletons in OO programming languages with namespaces and classes.

This is a singleton in JavaScript (assuming global scope):

const ProcessManager = {
  numProcess: 0,
  increment() {
    this.numProcess++
  }
}

Now I'm not saying it cannot be done that way, but having this implementation is more true to the nature of JavaScript.
tracker1 1482 days ago. link 2 points
Even then... most modern JS is written in modules (cjs or esm)...

    //module singleton...
    let numProcess = 0;

    export default { // or module.exports for cjs
      increment: () => numProcess++,
    };

Can still have the internal numProcess private.
joncys 1476 days ago. link 1 point
This is a very good addition recognising the implicit module environment we're all most probably working in (leveraging tools like Webpack, etc.), thank you for sharing this!