Socket
Socket
Sign inDemoInstall

deprecation

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    deprecation

Log a deprecation message with stack


Version published
Weekly downloads
6.4M
increased by1.26%
Maintainers
1
Install size
4.81 kB
Created
Weekly downloads
 

Package description

What is deprecation?

The `deprecation` npm package is designed to help developers manage and signal deprecations within their codebase. It provides a structured way to mark certain functionalities as deprecated, issue warnings, and guide users towards alternatives or updated practices. This can be particularly useful in libraries or applications undergoing gradual upgrades or changes, ensuring backward compatibility while encouraging the adoption of new features or methods.

What are deprecation's main functionalities?

Emitting Deprecation Warnings

This feature allows developers to emit deprecation warnings with a unique ID and a message guiding users towards an alternative method or practice. The code sample demonstrates how to create a new `Deprecation` instance associated with a specific package and issue a warning about a deprecated method.

"use strict";
const Deprecation = require('deprecation');

const deprecation = new Deprecation('@mycompany/mypackage');

deprecation.warn('deprecated-method', 'The `deprecatedMethod()` is deprecated and will be removed in the next major release. Use `newMethod()` instead.');

Other packages similar to deprecation

Readme

Source

deprecation

Log a deprecation message with stack

build

Usage

Browsers

Load deprecation directly from cdn.pika.dev

<script type="module">
  import { Deprecation } from "https://cdn.pika.dev/deprecation/v2";
</script>
Node

Install with npm install deprecation

const { Deprecation } = require("deprecation");
// or: import { Deprecation } from "deprecation";
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

License

ISC

Keywords

FAQs

Last updated on 13 Jun 2019

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc