mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 16:47:49 +00:00
add #times utility method.
_(3).times(alert) added tests and internal docs
This commit is contained in:
@@ -589,6 +589,13 @@
|
||||
_.identity = function(value) {
|
||||
return value;
|
||||
};
|
||||
|
||||
// run a function n times.
|
||||
// looks good in wrapper form:
|
||||
// _(3).times(alert)
|
||||
_.times = function (n, fn, context) {
|
||||
for (var i=0; i < n; i++) fn.call(context, i)
|
||||
};
|
||||
|
||||
// Break out of the middle of an iteration.
|
||||
_.breakLoop = function() {
|
||||
|
||||
Reference in New Issue
Block a user