Files
lodash/internal/pickByArray.js
John-David Dalton 26837e7fe2 Bump to v3.8.0.
2015-12-16 17:50:05 -08:00

30 lines
657 B
JavaScript

define(['./toObject'], function(toObject) {
/**
* A specialized version of `_.pick` which picks `object` properties specified
* by `props`.
*
* @private
* @param {Object} object The source object.
* @param {string[]} props The property names to pick.
* @returns {Object} Returns the new object.
*/
function pickByArray(object, props) {
object = toObject(object);
var index = -1,
length = props.length,
result = {};
while (++index < length) {
var key = props[index];
if (key in object) {
result[key] = object[key];
}
}
return result;
}
return pickByArray;
});