mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
build in functionality to at, add string support, optimize, and add more tests
Former-commit-id: 951ef27e55fff5a70d09916b55b85f9e725f751a
This commit is contained in:
16
lodash.js
16
lodash.js
@@ -1956,8 +1956,20 @@
|
||||
* _.at( ['lodash', 'javascript', 'fast'], 0, 2 );
|
||||
* // => ['lodash, 'fast']
|
||||
*/
|
||||
function at(collection, list) {
|
||||
return values(pick(collection || [], concat.apply(arguments, slice(arguments, 1))));
|
||||
function at(collection) {
|
||||
var index = -1,
|
||||
props = concat.apply(arrayRef, slice(arguments, 1)),
|
||||
length = props.length,
|
||||
result = Array(length);
|
||||
|
||||
if (noCharByIndex && isString(collection)) {
|
||||
collection = collection.split('');
|
||||
}
|
||||
|
||||
while(++index < length) {
|
||||
result[index] = collection[props[index]];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user