semantic-branch-version/node_modules/deprecation
2020-07-04 15:41:06 +02:00
..
dist-node Checking node_modules 2020-07-04 15:41:06 +02:00
dist-src Checking node_modules 2020-07-04 15:41:06 +02:00
dist-types Checking node_modules 2020-07-04 15:41:06 +02:00
dist-web Checking node_modules 2020-07-04 15:41:06 +02:00
LICENSE Checking node_modules 2020-07-04 15:41:06 +02:00
package.json Checking node_modules 2020-07-04 15:41:06 +02:00
README.md Checking node_modules 2020-07-04 15:41:06 +02:00

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