Add lazy invokeMap.

This commit is contained in:
John-David Dalton
2015-11-24 16:49:59 -08:00
parent 6dc92df880
commit 7bd986337a
2 changed files with 30 additions and 0 deletions

View File

@@ -7148,6 +7148,27 @@
assert.deepEqual(_.invokeMap([object], path), [1]);
});
});
QUnit.test('should support shortcut fusion', function(assert) {
assert.expect(2);
if (!isNpm) {
var count = 0,
method = function() { count++; return this.index; };
var array = lodashStable.times(LARGE_ARRAY_SIZE, function(index) {
return { 'index': index, 'method': method };
});
var actual = _(array).invokeMap('method').take(1).value();
assert.strictEqual(count, 1);
assert.deepEqual(actual, [0]);
}
else {
skipTest(assert, 2);
}
});
}());
/*--------------------------------------------------------------------------*/