Skip to content

Create an instance of your javascript class without `new` keyword

Notifications You must be signed in to change notification settings

frank-lemanschik/class-nonew-decorator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

class-nonew-decorator

semantic-release Build Status Commitizen friendly devDependency Status Coverage Status

Allows to create an Instance from a JavaScript Class without invoking new keyword.

Install

npm i class-nonew-decorator --save

Use with ES6

import nonew from 'class-nonew-decorator';

@nonew()
class IamClass {
    constructor() {
        console.log('IamClass Instance!');
    }
}

console.log(new IamClass() instanceof IamClass);  // true

console.log(IamClass() instanceof IamClass);  // true

Use with CJS

const nonew = require('class-nonew-decorator');

@nonew()
class IamClass {
    constructor() {
        console.log('IamClass Instance!');
    }
}

console.log(new IamClass() instanceof IamClass);  // true

console.log(IamClass() instanceof IamClass);  // true

About

Create an instance of your javascript class without `new` keyword

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published