Skip to content

Suppresses deprecation warnings in a given function.

License

Notifications You must be signed in to change notification settings

TapuCosmo/no-deprecation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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]

About

Suppresses deprecation warnings in a given function.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published