* Creates a shallow clone of `object` composed of the specified properties. * Property names may be specified as individual arguments or as arrays of * property names. If a callback is provided it will be executed for each * property of `object` picking the properties the callback ret
(object, callback, thisArg)
| 37947 | * // => { 'name': 'fred' } |
| 37948 | */ |
| 37949 | function pick(object, callback, thisArg) { |
| 37950 | var result = {}; |
| 37951 | if (typeof callback != 'function') { |
| 37952 | var index = -1, |
| 37953 | props = baseFlatten(arguments, true, false, 1), |
| 37954 | length = isObject(object) ? props.length : 0; |
| 37955 | |
| 37956 | while (++index < length) { |
| 37957 | var key = props[index]; |
| 37958 | if (key in object) { |
| 37959 | result[key] = object[key]; |
| 37960 | } |
| 37961 | } |
| 37962 | } else { |
| 37963 | callback = lodash.createCallback(callback, thisArg, 3); |
| 37964 | forIn(object, function(value, key, object) { |
| 37965 | if (callback(value, key, object)) { |
| 37966 | result[key] = value; |
| 37967 | } |
| 37968 | }); |
| 37969 | } |
| 37970 | return result; |
| 37971 | } |
| 37972 | |
| 37973 | /** |
| 37974 | * An alternative to `_.reduce` this method transforms `object` to a new |
nothing calls this directly
no test coverage detected