import { default } from "https://deno.land/x/ayonli_jsext@v0.9.72/deprecate.ts";
Marks a function as deprecated and returns a wrapped function.
When the wrapped function is called, a deprecation warning will be emitted to the stdout.
NOTE: The original function must have a name.
NOTE: This function is experimental and the warning may point to the wrong file source in some environments.
Examples
Example 1
Example 1
import deprecate from "@ayonli/jsext/deprecate";
const sum = deprecate(function sum(a: number, b: number) {
return a + b;
}, "use `a + b` instead");
console.log(sum(1, 2));
// output:
// DeprecationWarning: sum() is deprecated, use `a + b` instead (at <anonymous>:4:13)
// 3
Type Parameters
Fn extends (this: T, ...args: any[]) => any
Parameters
fn: Fn
Extra tip for the user to migrate.
Emits a deprecation warning for the target, usually a parameter, an option, or the function's name, etc.
Examples
Example 1
Example 1
import deprecate from "@ayonli/jsext/deprecate";
function pow(a: number, b: number) {
deprecate("pow()", pow, "use `a ** b` instead");
return a ** b;
}
console.log(pow(2, 3));
// output:
// DeprecationWarning: pow() is deprecated, use `a ** b` instead (at <anonymous>:5:13)
// 3