Created
March 9, 2022 07:52
-
-
Save julien-f/b1a155fef1173c7b82e532f9bc28eb7c to your computer and use it in GitHub Desktop.
Deprecate function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
exports.deprecate = function deprecate(fn, message) { | |
let warned = false; | |
return function deprecated() { | |
if (!warned) { | |
warned = true; | |
console.warn(new Error(message)); | |
} | |
return fn.apply(this, arguments); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment