mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-25 13:39:06 -05:00
added Common.deprecated
This commit is contained in:
parent
6957dbff63
commit
ffa31937f0
1 changed files with 15 additions and 0 deletions
|
@ -373,6 +373,21 @@ module.exports = Common;
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Shows a deprecated console warning when the function on the given object is called.
|
||||
* The target function will be replaced with a new function that first shows the warning
|
||||
* and then calls the original function.
|
||||
* @method deprecated
|
||||
* @param {object} obj The object or module
|
||||
* @param {string} name The property name of the function on obj
|
||||
* @param {string} warning The one-time message to show if the function is called
|
||||
*/
|
||||
Common.deprecated = function(obj, prop, warning) {
|
||||
obj[prop] = Common.chain(function() {
|
||||
Common.warnOnce('🔅 deprecated 🔅', warning);
|
||||
}, obj[prop]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the next unique sequential ID.
|
||||
* @method nextId
|
||||
|
|
Loading…
Reference in a new issue