mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Make _.times implicitly end a chain sequence.
This commit is contained in:
12
lodash.js
12
lodash.js
@@ -1503,7 +1503,7 @@
|
|||||||
* `pullAllBy`, `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`,
|
* `pullAllBy`, `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`,
|
||||||
* `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sort`,
|
* `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sort`,
|
||||||
* `sortBy`, `sortByOrder`, `splice`, `spread`, `tail`, `take`, `takeRight`,
|
* `sortBy`, `sortByOrder`, `splice`, `spread`, `tail`, `take`, `takeRight`,
|
||||||
* `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`,
|
* `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
|
||||||
* `toPath`, `toPlainObject`, `transform`, `unary`, `union`, `unionBy`,
|
* `toPath`, `toPlainObject`, `transform`, `unary`, `union`, `unionBy`,
|
||||||
* `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, `unshift`, `unzip`,
|
* `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, `unshift`, `unzip`,
|
||||||
* `unzipWith`, `values`, `valuesIn`, `without`, `wrap`, `xor`, `xorBy`,
|
* `unzipWith`, `values`, `valuesIn`, `without`, `wrap`, `xor`, `xorBy`,
|
||||||
@@ -1526,10 +1526,10 @@
|
|||||||
* `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`,
|
* `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`,
|
||||||
* `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
|
* `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
|
||||||
* `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`,
|
* `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`,
|
||||||
* `startsWith`, `subtract`, `sum`, sumBy`, `template`, `toLower`, `toInteger`,
|
* `startsWith`, `subtract`, `sum`, sumBy`, `template`, `times`, `toLower`,
|
||||||
* `toLength`, `toNumber`, `toSafeInteger`, toString`, `toUpper`, `trim`,
|
* `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, toString`, `toUpper`,
|
||||||
* `trimLeft`, `trimRight`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
|
* `trim`, `trimLeft`, `trimRight`, `truncate`, `unescape`, `uniqueId`,
|
||||||
* `upperFirst`, `value`, and `words`
|
* `upperCase`, `upperFirst`, `value`, and `words`
|
||||||
*
|
*
|
||||||
* @name _
|
* @name _
|
||||||
* @constructor
|
* @constructor
|
||||||
@@ -13644,7 +13644,6 @@
|
|||||||
lodash.tap = tap;
|
lodash.tap = tap;
|
||||||
lodash.throttle = throttle;
|
lodash.throttle = throttle;
|
||||||
lodash.thru = thru;
|
lodash.thru = thru;
|
||||||
lodash.times = times;
|
|
||||||
lodash.toArray = toArray;
|
lodash.toArray = toArray;
|
||||||
lodash.toPath = toPath;
|
lodash.toPath = toPath;
|
||||||
lodash.toPlainObject = toPlainObject;
|
lodash.toPlainObject = toPlainObject;
|
||||||
@@ -13794,6 +13793,7 @@
|
|||||||
lodash.sum = sum;
|
lodash.sum = sum;
|
||||||
lodash.sumBy = sumBy;
|
lodash.sumBy = sumBy;
|
||||||
lodash.template = template;
|
lodash.template = template;
|
||||||
|
lodash.times = times;
|
||||||
lodash.toInteger = toInteger;
|
lodash.toInteger = toInteger;
|
||||||
lodash.toLength = toLength;
|
lodash.toLength = toLength;
|
||||||
lodash.toLower = toLower;
|
lodash.toLower = toLower;
|
||||||
|
|||||||
23
test/test.js
23
test/test.js
@@ -19287,7 +19287,7 @@
|
|||||||
QUnit.test('should return an array of the results of each `iteratee` execution', function(assert) {
|
QUnit.test('should return an array of the results of each `iteratee` execution', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
assert.deepEqual(_.times(3, function(n) { return n * 2; }), [0, 2, 4]);
|
assert.deepEqual(_.times(3, doubled), [0, 2, 4]);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should return an empty array for falsey and negative `n` arguments', function(assert) {
|
QUnit.test('should return an empty array for falsey and negative `n` arguments', function(assert) {
|
||||||
@@ -19303,16 +19303,25 @@
|
|||||||
assert.deepEqual(actual, expected);
|
assert.deepEqual(actual, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should return a wrapped value when chaining', function(assert) {
|
QUnit.test('should return an unwrapped value when implicitly chaining', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(1);
|
||||||
|
|
||||||
if (!isNpm) {
|
if (!isNpm) {
|
||||||
var wrapped = _(3).times();
|
assert.deepEqual(_(3).times(), [0, 1, 2]);
|
||||||
assert.ok(wrapped instanceof _);
|
|
||||||
assert.deepEqual(wrapped.value(), [0, 1, 2]);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert, 2);
|
skipTest(assert);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.test('should return a wrapped value when explicitly chaining', function(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
if (!isNpm) {
|
||||||
|
assert.ok(_(3).chain().times() instanceof _);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipTest(assert);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|||||||
Reference in New Issue
Block a user