nonew

Allows constructor functions to be called without using new

Usage no npm install needed!

<script type="module">
  import nonew from 'https://cdn.skypack.dev/nonew';
</script>

README

nonew.js

Allows constructor functions to be called without using new

Example

Consider this constructor function:

function Person(name) {
  this.name = name;
}

Normally to instantiate it, we'd do:

var myself = new Person('Corey Farwell');

With nonew.js, we can create an alternate constructor that doesn't require the use of new:

var nonew = require('nonew');

var person = nonew(Person);

Now we can do:

var myself = person('Corey Farwell');

License

Mozilla Public License version 2