Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
clean-decorators
Advanced tools
clean-decorators
is a small utility library to cleanup subscriptions from observables on a method call.
It takes any property that has a unsubscribe
method. If the property is undefined/null or has no unsubscribe
method at the time
of the cleanup. Nothing will happen.
npm install clean-decorators
reflect-metadata
The library has a dependency on reflect-metadata
but does not import it. You need to import it yourself.
@Cleanable
defines a cleanable property.
@Clean
unsubscribes every property defined by the @Cleanable decorators.
class MyClass {
@Cleanable() myProperty: any;
@Cleanable() myProperty2: any;
constructor () {
this.myProperty = /* observable.subscribe(() => {}) */
this.myProperty2 = /* observable2.subscribe(() => {}) */
}
@Clean()
clean () {
// Now myProperty and myProperty2 are unsubscribed
}
}
@Cleanable()
takes CleanableMetadata
which is an object containing an id. By default, this id is an empty string.
The @Clean()
decorator also takes an id in his CleanMetadata
options.
It can be useful if you need two categories of subscriptions that you want to unsubscribe in different methods.
class MyClass {
@Cleanable({ id: 'a' }) myProperty: any;
@Cleanable({ id: 'b' }) myProperty2: any;
constructor () {
this.myProperty = /* observable.subscribe(() => {}) */
this.myProperty2 = /* observable2.subscribe(() => {}) */
}
@Clean({ id: 'a' })
cleanA () {
// Now myProperty is unsubscribed
}
@Clean({ id: 'b' })
cleanB () {
// Now myProperty2 is unsubscribed
}
}
The CleanMetadata
decorator also takes a before
parameter which defines if the decorator runs before the original method or otherwise.
FAQs
Decorators to clean up observable subscriptions
The npm package clean-decorators receives a total of 0 weekly downloads. As such, clean-decorators popularity was classified as not popular.
We found that clean-decorators 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.