UNPKG

473 BJavaScriptView Raw
1const deprecated = (msg, log = console.log) => function(target, prop, descriptor) {
2 const signature = `${target.constructor.name}#${prop.toString()}`;
3 const fn = descriptor.value;
4 if (typeof fn !== "function") {
5 throw new Error(`${signature} is not a function`);
6 }
7 descriptor.value = function() {
8 log(`DEPRECATED ${signature}: ${msg || "will be removed soon"}`);
9 return fn.apply(this, arguments);
10 };
11 return descriptor;
12};
13export {
14 deprecated
15};