0.0.6 • Published 1 month ago

@dozerg/no-new v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

No New

npm Downloads Build Status

Convert an ES6 class constructor to a normal function.

Install

npm i @dozerg/no-new

Usage

import noNew from '@dozerg/no-new';

class A {
  constructor(readonly i: number, readonly s: string) {}
}

const AA = noNew(A);

// Instead of calling new A(1, 'hello'), you can use:
const a = AA(1, 'hello');   // a is an object of class A

APIs

function noNew<T>(ctor: T): Function

Accept a class constructor, and return a function which will create an object of the class.

License

MIT © Zhao DAI daidodo@gmail.com

0.0.6

1 month ago

0.0.5

5 months ago

0.0.4

5 months ago

0.0.3

8 months ago

0.0.2

1 year ago

0.0.1

2 years ago