无新
将 ES6 类构建器转换为正常函数 .
安装
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
APIs 密码
function noNew<T>(ctor: T): Function
接受类构建器,并返回将创建类对象的函数.
许可证
麻省理工学院 达伊多多@gmail.com