A function to trigger deprecations.
Just run yarn install @mscs/deprecation
There a several usages:
Trigger with custom message:
import { deprecate } from "@mscs/deprecation";
function deprecatedMethod(){
deprecate("deprecatedMethod is deprecated. Use something else instead.");
}
Trigger with the conventional message:
import { deprecate } from "@mscs/deprecation";
function deprecatedMethod(){
deprecate(3, 4, 6);
}
You can change behaviour by set the triggerHandler
method.
import { deprecate, defaultDeprecationTriggerHandler } from "@mscs/deprecation";
deprecate.triggerHandler = (message: string, error: Error) => {
// Perform the default behaviour.
defaultDeprecationTriggerHandler(message, error)
// Send deprecation to an endpoint
fetch("https://my-server.tld/api/deprecation", {
method: 'POST',
body: JSON.stringify({ message, error }),
})
.catch(console.error);
}
function deprecatedMethod(){
deprecate(3, 4, 6);
}