JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7329
  • Score
    100M100P100Q131557F
  • License MIT

Convert ES6 class constructor to normal function.

Package Exports

  • @dozerg/no-new
  • @dozerg/no-new/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@dozerg/no-new) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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