0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-23 09:26:51 -05:00

added Common.warnOnce

This commit is contained in:
liabru 2021-03-23 23:59:52 +00:00
parent 3ac3498712
commit 6957dbff63

View file

@ -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