
Product
Introducing GitHub Actions Scanning Support
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
deprecation
Advanced tools
Log a deprecation message with stack
| Browsers |
Load
|
|---|---|
| Node |
Install with
|
function foo() {
bar();
}
function bar() {
baz();
}
function baz() {
console.warn(new Deprecation("[my-lib] foo() is deprecated, use bar()"));
}
foo();
// { Deprecation: [my-lib] foo() is deprecated, use bar()
// at baz (/path/to/file.js:12:15)
// at bar (/path/to/file.js:8:3)
// at foo (/path/to/file.js:4:3)
To log a deprecation message only once, you can use the once module.
const Deprecation = require("deprecation");
const once = require("once");
const deprecateFoo = once(console.warn);
function foo() {
deprecateFoo(new Deprecation("[my-lib] foo() is deprecated, use bar()"));
}
foo();
foo(); // logs nothing
The `depd` package is similar to `deprecation` in that it provides a way to declare deprecations and issue warnings in Node.js applications. However, `depd` focuses more on a minimalistic approach and is widely used for expressing deprecations in middleware or frameworks. It automatically handles the generation of detailed deprecation messages, including the stack trace to the deprecated call, which differs from `deprecation`'s more manual and message-centric approach.
The `warning` package is another tool for managing warnings in JavaScript applications, not limited to deprecations. It allows developers to print warning messages to the console if a condition fails, which can be used for deprecations but also for other types of warnings. Compared to `deprecation`, `warning` is more general-purpose and does not specifically focus on package or method deprecations.
FAQs
Log a deprecation message with stack
The npm package deprecation receives a total of 6,741,184 weekly downloads. As such, deprecation popularity was classified as popular.
We found that deprecation 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.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.

Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.

Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.