lodash.pick
Advanced tools
Comparing version 4.2.0 to 4.2.1
109
index.js
/** | ||
* lodash 4.2.0 (Custom Build) <https://lodash.com/> | ||
* lodash (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
@@ -12,3 +12,29 @@ * Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
/** Used as references for various `Number` constants. */ | ||
var INFINITY = 1 / 0; | ||
/** `Object#toString` result references. */ | ||
var symbolTag = '[object Symbol]'; | ||
/** | ||
* A specialized version of `_.map` for arrays without support for iteratee | ||
* shorthands. | ||
* | ||
* @private | ||
* @param {Array} array The array to iterate over. | ||
* @param {Function} iteratee The function invoked per iteration. | ||
* @returns {Array} Returns the new mapped array. | ||
*/ | ||
function arrayMap(array, iteratee) { | ||
var index = -1, | ||
length = array.length, | ||
result = Array(length); | ||
while (++index < length) { | ||
result[index] = iteratee(array[index], index, array); | ||
} | ||
return result; | ||
} | ||
/** | ||
* A specialized version of `_.reduce` for arrays without support for | ||
@@ -38,3 +64,13 @@ * iteratee shorthands. | ||
/** Used for built-in method references. */ | ||
var objectProto = Object.prototype; | ||
/** | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objectToString = objectProto.toString; | ||
/** | ||
* The base implementation of `_.pick` without support for individual | ||
@@ -59,2 +95,68 @@ * property identifiers. | ||
/** | ||
* Converts `value` to a string key if it's not a string or symbol. | ||
* | ||
* @private | ||
* @param {*} value The value to inspect. | ||
* @returns {string|symbol} Returns the key. | ||
*/ | ||
function toKey(value) { | ||
if (typeof value == 'string' || isSymbol(value)) { | ||
return value; | ||
} | ||
var result = (value + ''); | ||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; | ||
} | ||
/** | ||
* Checks if `value` is object-like. A value is object-like if it's not `null` | ||
* and has a `typeof` result of "object". | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is object-like, else `false`. | ||
* @example | ||
* | ||
* _.isObjectLike({}); | ||
* // => true | ||
* | ||
* _.isObjectLike([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isObjectLike(_.noop); | ||
* // => false | ||
* | ||
* _.isObjectLike(null); | ||
* // => false | ||
*/ | ||
function isObjectLike(value) { | ||
return !!value && typeof value == 'object'; | ||
} | ||
/** | ||
* Checks if `value` is classified as a `Symbol` primitive or object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, | ||
* else `false`. | ||
* @example | ||
* | ||
* _.isSymbol(Symbol.iterator); | ||
* // => true | ||
* | ||
* _.isSymbol('abc'); | ||
* // => false | ||
*/ | ||
function isSymbol(value) { | ||
return typeof value == 'symbol' || | ||
(isObjectLike(value) && objectToString.call(value) == symbolTag); | ||
} | ||
/** | ||
* Creates an object composed of the picked `object` properties. | ||
@@ -67,4 +169,3 @@ * | ||
* @param {Object} object The source object. | ||
* @param {...(string|string[])} [props] The property identifiers to pick, | ||
* specified individually or in arrays. | ||
* @param {...(string|string[])} [props] The property identifiers to pick. | ||
* @returns {Object} Returns the new object. | ||
@@ -79,5 +180,5 @@ * @example | ||
var pick = rest(function(object, props) { | ||
return object == null ? {} : basePick(object, baseFlatten(props, 1)); | ||
return object == null ? {} : basePick(object, arrayMap(baseFlatten(props, 1), toKey)); | ||
}); | ||
module.exports = pick; |
{ | ||
"name": "lodash.pick", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"description": "The lodash method `_.pick` exported as a module.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://lodash.com/", |
@@ -1,2 +0,2 @@ | ||
# lodash.pick v4.2.0 | ||
# lodash.pick v4.2.1 | ||
@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.pick` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [documentation](https://lodash.com/docs#pick) or [package source](https://github.com/lodash/lodash/blob/4.2.0-npm-packages/lodash.pick) for more details. | ||
See the [documentation](https://lodash.com/docs#pick) or [package source](https://github.com/lodash/lodash/blob/4.2.1-npm-packages/lodash.pick) for more details. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7888
165