mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07:49 +00:00
Remove _.at guard for _.map use.
This commit is contained in:
@@ -3610,17 +3610,12 @@
|
|||||||
* _.at(['fred', 'barney', 'pebbles'], 0, 2);
|
* _.at(['fred', 'barney', 'pebbles'], 0, 2);
|
||||||
* // => ['fred', 'pebbles']
|
* // => ['fred', 'pebbles']
|
||||||
*/
|
*/
|
||||||
function at(collection, guard) {
|
function at(collection) {
|
||||||
var args = arguments,
|
var args = arguments,
|
||||||
index = -1,
|
index = -1,
|
||||||
props = baseFlatten(args, true, false, 1),
|
props = baseFlatten(args, true, false, 1),
|
||||||
length = props.length,
|
length = props.length;
|
||||||
type = typeof guard;
|
|
||||||
|
|
||||||
// enables use as a callback for functions like `_.map`
|
|
||||||
if ((type == 'number' || type == 'string') && args[2] && args[2][guard] === collection) {
|
|
||||||
length = 1;
|
|
||||||
}
|
|
||||||
if (support.unindexedChars && isString(collection)) {
|
if (support.unindexedChars && isString(collection)) {
|
||||||
collection = collection.split('');
|
collection = collection.split('');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -693,13 +693,6 @@
|
|||||||
deepEqual(actual, [1, 3]);
|
deepEqual(actual, [1, 3]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should work when used as a callback for `_.map`', 1, function() {
|
|
||||||
var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],
|
|
||||||
actual = _.map(array, _.at);
|
|
||||||
|
|
||||||
deepEqual(actual, [[1], [5], [9]]);
|
|
||||||
});
|
|
||||||
|
|
||||||
_.each({
|
_.each({
|
||||||
'literal': 'abc',
|
'literal': 'abc',
|
||||||
'object': Object('abc')
|
'object': Object('abc')
|
||||||
|
|||||||
Reference in New Issue
Block a user