deprecation
TypeScript icon, indicating that this package has built-in type declarations

2.3.1 • Public • Published

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.3.1
    6,369,036
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.3.1
    6,369,036
  • 2.3.0
    10
  • 2.2.0
    2
  • 2.1.0
    1
  • 2.0.0
    4,919
  • 1.0.1
    8,660
  • 1.0.0
    1

Package Sidebar

Install

npm i deprecation

Weekly Downloads

6,382,629

Version

2.3.1

License

ISC

Unpacked Size

4.01 kB

Total Files

7

Last publish

Collaborators

  • gr2m