SIGN IN SIGN UP

A modern JavaScript utility library delivering modularity, performance, & extras.

0 0 9 JavaScript
2016-01-28 01:16:24 -08:00
define(['./get'], function(get) {
2015-01-08 00:37:01 -08:00
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
2015-12-16 17:53:20 -08:00
* The base implementation of `_.at` without support for individual paths.
2015-01-08 00:37:01 -08:00
*
* @private
2015-12-16 17:53:20 -08:00
* @param {Object} object The object to iterate over.
2016-11-13 22:49:46 -08:00
* @param {string[]} paths The property paths to pick.
2016-05-07 11:49:46 -07:00
* @returns {Array} Returns the picked elements.
2015-01-08 00:37:01 -08:00
*/
2015-12-16 17:53:20 -08:00
function baseAt(object, paths) {
2015-01-08 00:37:01 -08:00
var index = -1,
2015-12-16 17:53:20 -08:00
length = paths.length,
2016-10-30 20:06:57 -07:00
result = Array(length),
skip = object == null;
2015-01-08 00:37:01 -08:00
2015-12-16 17:53:20 -08:00
while (++index < length) {
2016-10-30 20:06:57 -07:00
result[index] = skip ? undefined : get(object, paths[index]);
2015-01-08 00:37:01 -08:00
}
return result;
}
return baseAt;
});