Skip to content

Commit

Permalink
added Common.deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Mar 24, 2021
1 parent 6957dbf commit ffa3193
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/core/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ffa3193

Please sign in to comment.