From 6957dbff636b82d314bfc452c20a258b07d6b5f1 Mon Sep 17 00:00:00 2001 From: liabru Date: Tue, 23 Mar 2021 23:59:52 +0000 Subject: [PATCH] added Common.warnOnce --- src/core/Common.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/core/Common.js b/src/core/Common.js index f03de7b..63892a5 100644 --- a/src/core/Common.js +++ b/src/core/Common.js @@ -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