mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 00:57:48 +00:00
Bump to v3.0.0.
This commit is contained in:
28
internal/pickByArray.js
Normal file
28
internal/pickByArray.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import toObject from './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;
|
||||
}
|
||||
|
||||
export default pickByArray;
|
||||
Reference in New Issue
Block a user