
Security News
Bun 1.2.19 Adds Isolated Installs for Better Monorepo Support
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
@activeprospect/old
Advanced tools
Make the 'new' keyword optional for ES6 classes
npm install old
var old = require('old')
class Class {
// ...
}
var Class2 = old(Class)
Class() // throws error
Class2() // creates an instance of Class
With ES5 "constructor" functions, a common pattern is to make the new
keyword optional by doing something like the following:
function Foo () {
if (!(this instanceof Foo)) return new Foo()
// do constructor stuff
}
Recently, ES6 introduced classes to replace constructor functions. However, if these classes are instantiated without new
, an error is thrown: TypeError: Class constructor Foo cannot be invoked without 'new'
. This module makes new
optional, even for these ES6 classes.
FAQs
Make the 'new' keyword optional for ES6 classes
We found that @activeprospect/old demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 20 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
Security News
Popular npm packages like eslint-config-prettier were compromised after a phishing attack stole a maintainer’s token, spreading malicious updates.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.