Skip to content

Commit

Permalink
added Common.warnOnce
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Mar 23, 2021
1 parent 3ac3498 commit 6957dbf
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 @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6957dbf

Please sign in to comment.