no-deprecation
v1.0.0
Published
Suppresses deprecation warnings in a given function.
Downloads
11
Maintainers
Readme
No Deprecation
Wraps functions to remove deprecation warnings.
Normal Wrapping
const noDeprecation = require("no-deprecation");
const util = require("util");
const deprecatedFunction = util.deprecate(function () {
return "Hello World!";
});
const undeprecatedFunction = noDeprecation(deprecatedFunction);
console.log(undeprecatedFunction());
// -> "Hello World!", with no deprecation warning
Wrapping With this
const noDeprecation = require("no-deprecation");
const util = require("util");
Array.prototype.replaceFirst = util.deprecate(function (data) {
this[0] = data;
});
const array = [1, 2, 3];
const undeprecatedFunction = noDeprecation(Array.prototype.replaceFirst, array);
undeprecatedFunction(1337); // No deprecation warning
console.log(array);
// -> [1337, 2, 3]