Package Exports
- deprecation
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (deprecation) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
deprecation
Log a deprecation message with stack
Usage
Browsers |
Load <script type="module">
import { Deprecation } from "https://cdn.pika.dev/deprecation/v2";
</script> |
---|---|
Node |
Install with 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