Convert an ES6 class constructor to a normal function.
npm i @dozerg/no-new
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
Accept a class constructor, and return a function which will create an object of the class.
MIT © Zhao DAI daidodo@gmail.com