
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@keenondrums/singleton
Advanced tools
Singleton. No constructor monkeypatching. Zero dependencies. Built with TypeScript.
Singleton. No constructor monkeypatching. Zero dependencies. Built with TypeScript.
Run
npm i @keenondrums/singleton
(Optional) Enable decorators
If you use TypeScript set in you tsconfig.json
{
"compilerOptions": {
"experimentalDecorators": true
}
}
If you use JavaScript configure your babel to support decorators and class properties
import { singleton } from '@keenondrums/singleton'
@singleton
class Test {}
new Test() === new Test() // returns `true`
import { singleton } from '@keenondrums/singleton'
class Test {}
const TestSingleton = singleton(Test)
new TestSingleton() === new TestSingleton() // returns `true`
Any child of your singleton will not be a singleton.
import { singleton } from '@keenondrums/singleton'
@singleton
class Parent {}
class Child extends Parent {}
new Child() === new Child() // returns `false`
// If you want to make `Child` a singleton as well, apply `singleton` decorator directly to it
@singleton
class ChildSingleton extends Parent {}
new ChildSingleton() === new ChildSingleton() // returns `true`
singleton decorator wraps your class with a Proxy and a construct trap to override class' creation logic.
Your singleton instance is always available as a static property of a class by key SINGLETON_KEY.
import { singleton, SINGLETON_KEY } from '@keenondrums/singleton'
@singleton
class Test {}
const instance = new Test()
Test[SINGLETON_KEY] === instance // returns `true`
FAQs
Singleton. No constructor monkeypatching. Zero dependencies. Built with TypeScript.
The npm package @keenondrums/singleton receives a total of 183 weekly downloads. As such, @keenondrums/singleton popularity was classified as not popular.
We found that @keenondrums/singleton demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.