@jswork/next-stub-singleton

Stub code for singleton.

Usage no npm install needed!

<script type="module">
  import jsworkNextStubSingleton from 'https://cdn.skypack.dev/@jswork/next-stub-singleton';
</script>

README

next-stub-singleton

Stub code for singleton.

version license size download

installation

npm install -S @jswork/next-stub-singleton

usage

import '@jswork/next-stub-singleton';

class App {}
Object.assign(App, nx.stubSingleton());
export default App;


// stub code:
{
  instance: null,
  getSingleton: function(){},
  getInstance: function() {
    if (!this.instance) {
      this.instance = new this();
    }
    return this.instance;
  }
}

license

Code released under the MIT license.