lodash.keysin
Advanced tools
Comparing version 3.0.8 to 4.0.0
389
index.js
/** | ||
* lodash 3.0.8 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modern modularize exports="npm" -o ./` | ||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
* lodash 4.0.0 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Available under MIT license <https://lodash.com/license> | ||
*/ | ||
var isArguments = require('lodash.isarguments'), | ||
isArray = require('lodash.isarray'); | ||
/** Used to detect unsigned integer values. */ | ||
var reIsUint = /^\d+$/; | ||
/** Used as references for various `Number` constants. */ | ||
var MAX_SAFE_INTEGER = 9007199254740991; | ||
/** Used for native method references. */ | ||
var objectProto = Object.prototype; | ||
/** `Object#toString` result references. */ | ||
var argsTag = '[object Arguments]', | ||
funcTag = '[object Function]', | ||
genTag = '[object GeneratorFunction]', | ||
stringTag = '[object String]'; | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
/** Used to detect unsigned integer values. */ | ||
var reIsUint = /^(?:0|[1-9]\d*)$/; | ||
/** | ||
* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) | ||
* of an array-like value. | ||
* The base implementation of `_.times` without support for iteratee shorthands | ||
* or max array length checks. | ||
* | ||
* @private | ||
* @param {number} n The number of times to invoke `iteratee`. | ||
* @param {Function} iteratee The function invoked per iteration. | ||
* @returns {Array} Returns the array of results. | ||
*/ | ||
var MAX_SAFE_INTEGER = 9007199254740991; | ||
function baseTimes(n, iteratee) { | ||
var index = -1, | ||
result = Array(n); | ||
while (++index < n) { | ||
result[index] = iteratee(index); | ||
} | ||
return result; | ||
} | ||
/** | ||
@@ -42,9 +56,266 @@ * Checks if `value` is a valid array-like index. | ||
/** | ||
* Checks if `value` is a valid array-like length. | ||
* Converts `iterator` to an array. | ||
* | ||
* **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength). | ||
* @private | ||
* @param {Object} iterator The iterator to convert. | ||
* @returns {Array} Returns the converted array. | ||
*/ | ||
function iteratorToArray(iterator) { | ||
var data, | ||
result = []; | ||
while (!(data = iterator.next()).done) { | ||
result.push(data.value); | ||
} | ||
return result; | ||
} | ||
/** Used for built-in method references. */ | ||
var objectProto = global.Object.prototype; | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
/** | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objectToString = objectProto.toString; | ||
/** Built-in value references. */ | ||
var Reflect = global.Reflect, | ||
enumerate = Reflect ? Reflect.enumerate : undefined, | ||
propertyIsEnumerable = objectProto.propertyIsEnumerable; | ||
/** | ||
* The base implementation of `_.keysIn` which doesn't skip the constructor | ||
* property of prototypes or treat sparse arrays as dense. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @returns {Array} Returns the array of property names. | ||
*/ | ||
function baseKeysIn(object) { | ||
object = object == null ? object : Object(object); | ||
var result = []; | ||
for (var key in object) { | ||
result.push(key); | ||
} | ||
return result; | ||
} | ||
// Fallback for IE < 9 with es6-shim. | ||
if (enumerate && !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf')) { | ||
baseKeysIn = function(object) { | ||
return iteratorToArray(enumerate(object)); | ||
}; | ||
} | ||
/** | ||
* The base implementation of `_.property` without support for deep paths. | ||
* | ||
* @private | ||
* @param {string} key The key of the property to get. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
function baseProperty(key) { | ||
return function(object) { | ||
return object == null ? undefined : object[key]; | ||
}; | ||
} | ||
/** | ||
* Gets the "length" property value of `object`. | ||
* | ||
* **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) | ||
* that affects Safari on at least iOS 8.1-8.3 ARM64. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @returns {*} Returns the "length" value. | ||
*/ | ||
var getLength = baseProperty('length'); | ||
/** | ||
* Creates an array of index keys for `object` values of arrays, | ||
* `arguments` objects, and strings, otherwise `null` is returned. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @returns {Array|null} Returns index keys, else `null`. | ||
*/ | ||
function indexKeys(object) { | ||
var length = object ? object.length : undefined; | ||
return (isLength(length) && (isArray(object) || isString(object) || isArguments(object))) | ||
? baseTimes(length, String) | ||
: null; | ||
} | ||
/** | ||
* Checks if `value` is likely a prototype object. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`. | ||
*/ | ||
function isPrototype(value) { | ||
var Ctor = value && value.constructor, | ||
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; | ||
return value === proto; | ||
} | ||
/** | ||
* Checks if `value` is likely an `arguments` object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. | ||
* @example | ||
* | ||
* _.isArguments(function() { return arguments; }()); | ||
* // => true | ||
* | ||
* _.isArguments([1, 2, 3]); | ||
* // => false | ||
*/ | ||
function isArguments(value) { | ||
// Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode. | ||
return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && | ||
(!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag); | ||
} | ||
/** | ||
* Checks if `value` is classified as an `Array` object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @type Function | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. | ||
* @example | ||
* | ||
* _.isArray([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isArray(document.body.children); | ||
* // => false | ||
* | ||
* _.isArray('abc'); | ||
* // => false | ||
* | ||
* _.isArray(_.noop); | ||
* // => false | ||
*/ | ||
var isArray = Array.isArray; | ||
/** | ||
* Checks if `value` is array-like. A value is considered array-like if it's | ||
* not a function and has a `value.length` that's an integer greater than or | ||
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @type Function | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is array-like, else `false`. | ||
* @example | ||
* | ||
* _.isArrayLike([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isArrayLike(document.body.children); | ||
* // => true | ||
* | ||
* _.isArrayLike('abc'); | ||
* // => true | ||
* | ||
* _.isArrayLike(_.noop); | ||
* // => false | ||
*/ | ||
function isArrayLike(value) { | ||
return value != null && | ||
!(typeof value == 'function' && isFunction(value)) && isLength(getLength(value)); | ||
} | ||
/** | ||
* This method is like `_.isArrayLike` except that it also checks if `value` | ||
* is an object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @type Function | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is an array-like object, else `false`. | ||
* @example | ||
* | ||
* _.isArrayLikeObject([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isArrayLikeObject(document.body.children); | ||
* // => true | ||
* | ||
* _.isArrayLikeObject('abc'); | ||
* // => false | ||
* | ||
* _.isArrayLikeObject(_.noop); | ||
* // => false | ||
*/ | ||
function isArrayLikeObject(value) { | ||
return isObjectLike(value) && isArrayLike(value); | ||
} | ||
/** | ||
* Checks if `value` is classified as a `Function` object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. | ||
* @example | ||
* | ||
* _.isFunction(_); | ||
* // => true | ||
* | ||
* _.isFunction(/abc/); | ||
* // => false | ||
*/ | ||
function isFunction(value) { | ||
// The use of `Object#toString` avoids issues with the `typeof` operator | ||
// in Safari 8 which returns 'object' for typed array constructors, and | ||
// PhantomJS 1.9 which returns 'function' for `NodeList` instances. | ||
var tag = isObject(value) ? objectToString.call(value) : ''; | ||
return tag == funcTag || tag == genTag; | ||
} | ||
/** | ||
* Checks if `value` is a valid array-like length. | ||
* | ||
* **Note:** This function is loosely based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`. | ||
* @example | ||
* | ||
* _.isLength(3); | ||
* // => true | ||
* | ||
* _.isLength(Number.MIN_VALUE); | ||
* // => false | ||
* | ||
* _.isLength(Infinity); | ||
* // => false | ||
* | ||
* _.isLength('3'); | ||
* // => false | ||
*/ | ||
@@ -72,3 +343,6 @@ function isLength(value) { | ||
* | ||
* _.isObject(1); | ||
* _.isObject(_.noop); | ||
* // => true | ||
* | ||
* _.isObject(null); | ||
* // => false | ||
@@ -84,2 +358,50 @@ */ | ||
/** | ||
* 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 _ | ||
* @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 `String` primitive or object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. | ||
* @example | ||
* | ||
* _.isString('abc'); | ||
* // => true | ||
* | ||
* _.isString(1); | ||
* // => false | ||
*/ | ||
function isString(value) { | ||
return typeof value == 'string' || | ||
(!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag); | ||
} | ||
/** | ||
* Creates an array of the own and inherited enumerable property names of `object`. | ||
@@ -107,23 +429,14 @@ * | ||
function keysIn(object) { | ||
if (object == null) { | ||
return []; | ||
} | ||
if (!isObject(object)) { | ||
object = Object(object); | ||
} | ||
var length = object.length; | ||
length = (length && isLength(length) && | ||
(isArray(object) || isArguments(object)) && length) || 0; | ||
var index = -1, | ||
isProto = isPrototype(object), | ||
props = baseKeysIn(object), | ||
propsLength = props.length, | ||
indexes = indexKeys(object), | ||
skipIndexes = !!indexes, | ||
result = indexes || [], | ||
length = result.length; | ||
var Ctor = object.constructor, | ||
index = -1, | ||
isProto = typeof Ctor == 'function' && Ctor.prototype === object, | ||
result = Array(length), | ||
skipIndexes = length > 0; | ||
while (++index < length) { | ||
result[index] = (index + ''); | ||
} | ||
for (var key in object) { | ||
if (!(skipIndexes && isIndex(key, length)) && | ||
while (++index < propsLength) { | ||
var key = props[index]; | ||
if (!(skipIndexes && (key == 'length' || isIndex(key, length))) && | ||
!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { | ||
@@ -130,0 +443,0 @@ result.push(key); |
{ | ||
"name": "lodash.keysin", | ||
"version": "3.0.8", | ||
"description": "The modern build of lodash’s `_.keysIn` as a module.", | ||
"version": "4.0.0", | ||
"description": "The lodash method `_.keysIn` exported as a module.", | ||
"homepage": "https://lodash.com/", | ||
"icon": "https://lodash.com/icon.svg", | ||
"license": "MIT", | ||
"keywords": "lodash, lodash-modularized, stdlib, util", | ||
"keywords": "lodash, lodash-modularized, stdlib, util, keysin", | ||
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | ||
"contributors": [ | ||
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | ||
"Benjamin Tan <demoneaux@gmail.com> (https://d10.github.io/)", | ||
"Blaine Bublitz <blaine@iceddev.com> (http://www.iceddev.com/)", | ||
"Kit Cambridge <github@kitcambridge.be> (http://kitcambridge.be/)", | ||
"Blaine Bublitz <blaine@iceddev.com> (https://github.com/phated)", | ||
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)" | ||
], | ||
"repository": "lodash/lodash", | ||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" }, | ||
"dependencies": { | ||
"lodash.isarguments": "^3.0.0", | ||
"lodash.isarray": "^3.0.0" | ||
} | ||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" } | ||
} |
@@ -1,4 +0,4 @@ | ||
# lodash.keysin v3.0.8 | ||
# lodash.keysin v4.0.0 | ||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.keysIn` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
The [lodash](https://lodash.com/) method `_.keysIn` exported as a [Node.js](https://nodejs.org/) module. | ||
@@ -8,3 +8,2 @@ ## Installation | ||
Using npm: | ||
```bash | ||
@@ -15,4 +14,3 @@ $ {sudo -H} npm i -g npm | ||
In Node.js/io.js: | ||
In Node.js: | ||
```js | ||
@@ -22,2 +20,2 @@ var keysIn = require('lodash.keysin'); | ||
See the [documentation](https://lodash.com/docs#keysIn) or [package source](https://github.com/lodash/lodash/blob/3.0.8-npm-packages/lodash.keysin) for more details. | ||
See the [documentation](https://lodash.com/docs#keysIn) or [package source](https://github.com/lodash/lodash/blob/4.0.0-npm-packages/lodash.keysin) 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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
13956
0
413
19
1
- Removedlodash.isarguments@^3.0.0
- Removedlodash.isarray@^3.0.0
- Removedlodash.isarguments@3.1.0(transitive)
- Removedlodash.isarray@3.0.4(transitive)