0
0
Fork 0
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:
liabru 2021-03-24 23:44:06 +00:00
parent 6957dbff63
commit ffa31937f0

View file

@ -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. * Returns the next unique sequential ID.
* @method nextId * @method nextId