🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@dozerg/no-new

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dozerg/no-new

Convert ES6 class constructor to normal function.

0.0.8
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

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

Keywords

new

FAQs

Package last updated on 21 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts