Skip to content

Commit 6957dbf

Browse files
committed
added Common.warnOnce
1 parent 3ac3498 commit 6957dbf

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/core/Common.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = Common;
1313
Common._nextId = 0;
1414
Common._seed = 0;
1515
Common._nowStartTime = +(new Date());
16+
Common._warnedOnce = {};
1617

1718
/**
1819
* Extends the object in the first argument using the object in the second argument.
@@ -358,6 +359,20 @@ module.exports = Common;
358359
}
359360
};
360361

362+
/**
363+
* Uses `Common.warn` to log the given message one time only.
364+
* @method warnOnce
365+
* @param ...objs {} The objects to log.
366+
*/
367+
Common.warnOnce = function() {
368+
var message = Array.prototype.slice.call(arguments).join(' ');
369+
370+
if (!Common._warnedOnce[message]) {
371+
Common.warn(message);
372+
Common._warnedOnce[message] = true;
373+
}
374+
};
375+
361376
/**
362377
* Returns the next unique sequential ID.
363378
* @method nextId

0 commit comments

Comments
 (0)