mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-25 13:39:06 -05:00
added Common.warnOnce
This commit is contained in:
parent
3ac3498712
commit
6957dbff63
1 changed files with 15 additions and 0 deletions
|
@ -13,6 +13,7 @@ module.exports = Common;
|
|||
Common._nextId = 0;
|
||||
Common._seed = 0;
|
||||
Common._nowStartTime = +(new Date());
|
||||
Common._warnedOnce = {};
|
||||
|
||||
/**
|
||||
* Extends the object in the first argument using the object in the second argument.
|
||||
|
@ -358,6 +359,20 @@ module.exports = Common;
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Uses `Common.warn` to log the given message one time only.
|
||||
* @method warnOnce
|
||||
* @param ...objs {} The objects to log.
|
||||
*/
|
||||
Common.warnOnce = function() {
|
||||
var message = Array.prototype.slice.call(arguments).join(' ');
|
||||
|
||||
if (!Common._warnedOnce[message]) {
|
||||
Common.warn(message);
|
||||
Common._warnedOnce[message] = true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the next unique sequential ID.
|
||||
* @method nextId
|
||||
|
|
Loading…
Reference in a new issue