nonew
v1.0.0
Published
Allows constructor functions to be called without using `new`
Downloads
6
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');