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.
deprecated-decorator
Advanced tools
The deprecated-decorator npm package provides a way to mark methods or classes as deprecated in JavaScript/TypeScript. This helps developers to signal that certain parts of the codebase should no longer be used and may be removed in future versions.
Deprecate a Method
This feature allows you to mark a method as deprecated. When the deprecated method is called, a warning message will be logged to the console.
const { deprecated } = require('deprecated-decorator');
class Example {
@deprecated('This method will be removed in future versions. Use newMethod instead.')
oldMethod() {
console.log('This is the old method.');
}
newMethod() {
console.log('This is the new method.');
}
}
const example = new Example();
example.oldMethod();
Deprecate a Class
This feature allows you to mark an entire class as deprecated. When an instance of the deprecated class is created, a warning message will be logged to the console.
const { deprecated } = require('deprecated-decorator');
@deprecated('This class will be removed in future versions. Use NewClass instead.')
class OldClass {
method() {
console.log('This is a method in the old class.');
}
}
class NewClass {
method() {
console.log('This is a method in the new class.');
}
}
const oldInstance = new OldClass();
oldInstance.method();
The core-decorators package provides a set of decorators for common use cases, including deprecation. It offers a more comprehensive set of decorators compared to deprecated-decorator, making it a more versatile choice for developers who need additional functionality beyond deprecation.
The deprecated package is another option for marking methods and classes as deprecated. It is similar in functionality to deprecated-decorator but offers a simpler API. It is a good choice for developers who need a straightforward solution for deprecation without additional features.
A simple decorator for deprecated properties, methods and classes.
npm install deprecated-decorator --save
Decorating a class will enable warning on constructor and static methods (including static getters and setters):
import deprecated from 'deprecated-decorator';
// alternative, since version, url
@deprecated('Bar', '0.1.0', 'http://vane.life/')
class Foo {
static method() { }
}
Or you can decorate methods respectively:
import deprecated from 'deprecated-decorator';
class Foo {
@deprecated('otherMethod')
method() { }
@deprecated('otherProperty')
get property() { }
}
MIT License.
FAQs
A simple decorator for deprecated methods and properties.
The npm package deprecated-decorator receives a total of 470,140 weekly downloads. As such, deprecated-decorator popularity was classified as popular.
We found that deprecated-decorator 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.