mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Bump to v3.0.0.
This commit is contained in:
29
internal/pickByArray.js
Normal file
29
internal/pickByArray.js
Normal file
@@ -0,0 +1,29 @@
|
||||
define(['./toObject'], function(toObject) {
|
||||
|
||||
/**
|
||||
* A specialized version of `_.pick` that picks `object` properties specified
|
||||
* by the `props` array.
|
||||
*
|
||||
* @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;
|
||||
});
|
||||
Reference in New Issue
Block a user