lodash._baseeach
Advanced tools
Comparing version 3.0.4 to 4.0.0
146
index.js
/** | ||
* lodash 3.0.4 (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> | ||
@@ -11,16 +11,25 @@ */ | ||
/** Used as references for various `Number` constants. */ | ||
var MAX_SAFE_INTEGER = 9007199254740991; | ||
/** `Object#toString` result references. */ | ||
var funcTag = '[object Function]', | ||
genTag = '[object GeneratorFunction]'; | ||
/** Used for built-in method references. */ | ||
var objectProto = global.Object.prototype; | ||
/** | ||
* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) | ||
* of an array-like value. | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var MAX_SAFE_INTEGER = 9007199254740991; | ||
var objectToString = objectProto.toString; | ||
/** | ||
* The base implementation of `_.forEach` without support for callback | ||
* shorthands and `this` binding. | ||
* The base implementation of `_.forEach` without support for iteratee shorthands. | ||
* | ||
* @private | ||
* @param {Array|Object|string} collection The collection to iterate over. | ||
* @param {Array|Object} collection The collection to iterate over. | ||
* @param {Function} iteratee The function invoked per iteration. | ||
* @returns {Array|Object|string} Returns `collection`. | ||
* @returns {Array|Object} Returns `collection`. | ||
*/ | ||
@@ -44,4 +53,3 @@ var baseEach = createBaseEach(baseForOwn); | ||
/** | ||
* The base implementation of `_.forOwn` without support for callback | ||
* shorthands and `this` binding. | ||
* The base implementation of `_.forOwn` without support for iteratee shorthands. | ||
* | ||
@@ -54,3 +62,3 @@ * @private | ||
function baseForOwn(object, iteratee) { | ||
return baseFor(object, iteratee, keys); | ||
return object && baseFor(object, iteratee, keys); | ||
} | ||
@@ -81,8 +89,11 @@ | ||
return function(collection, iteratee) { | ||
var length = collection ? getLength(collection) : 0; | ||
if (!isLength(length)) { | ||
if (collection == null) { | ||
return collection; | ||
} | ||
if (!isArrayLike(collection)) { | ||
return eachFunc(collection, iteratee); | ||
} | ||
var index = fromRight ? length : -1, | ||
iterable = toObject(collection); | ||
var length = collection.length, | ||
index = fromRight ? length : -1, | ||
iterable = Object(collection); | ||
@@ -99,3 +110,3 @@ while ((fromRight ? index-- : ++index < length)) { | ||
/** | ||
* Creates a base function for `_.forIn` or `_.forInRight`. | ||
* Creates a base function for methods like `_.forIn`. | ||
* | ||
@@ -108,9 +119,9 @@ * @private | ||
return function(object, iteratee, keysFunc) { | ||
var iterable = toObject(object), | ||
var index = -1, | ||
iterable = Object(object), | ||
props = keysFunc(object), | ||
length = props.length, | ||
index = fromRight ? length : -1; | ||
length = props.length; | ||
while ((fromRight ? index-- : ++index < length)) { | ||
var key = props[index]; | ||
while (length--) { | ||
var key = props[fromRight ? length : ++index]; | ||
if (iteratee(iterable[key], key, iterable) === false) { | ||
@@ -137,23 +148,81 @@ break; | ||
/** | ||
* Checks if `value` is a valid array-like length. | ||
* 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`. | ||
* | ||
* **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength). | ||
* @static | ||
* @memberOf _ | ||
* @type Function | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is array-like, else `false`. | ||
* @example | ||
* | ||
* @private | ||
* _.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)); | ||
} | ||
/** | ||
* 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 a valid length, else `false`. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. | ||
* @example | ||
* | ||
* _.isFunction(_); | ||
* // => true | ||
* | ||
* _.isFunction(/abc/); | ||
* // => false | ||
*/ | ||
function isLength(value) { | ||
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; | ||
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; | ||
} | ||
/** | ||
* Converts `value` to an object if it's not one. | ||
* Checks if `value` is a valid array-like length. | ||
* | ||
* @private | ||
* @param {*} value The value to process. | ||
* @returns {Object} Returns the object. | ||
* **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 | ||
*/ | ||
function toObject(value) { | ||
return isObject(value) ? value : Object(value); | ||
function isLength(value) { | ||
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; | ||
} | ||
@@ -178,3 +247,6 @@ | ||
* | ||
* _.isObject(1); | ||
* _.isObject(_.noop); | ||
* // => true | ||
* | ||
* _.isObject(null); | ||
* // => false | ||
@@ -181,0 +253,0 @@ */ |
{ | ||
"name": "lodash._baseeach", | ||
"version": "3.0.4", | ||
"description": "The modern build of lodash’s internal `baseEach` as a module.", | ||
"version": "4.0.0", | ||
"description": "The internal lodash function `baseEach` exported as a module.", | ||
"homepage": "https://lodash.com/", | ||
@@ -11,5 +11,3 @@ "icon": "https://lodash.com/icon.svg", | ||
"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/)" | ||
@@ -20,4 +18,4 @@ ], | ||
"dependencies": { | ||
"lodash.keys": "^3.0.0" | ||
"lodash.keys": "^4.0.0" | ||
} | ||
} |
@@ -1,4 +0,4 @@ | ||
# lodash._baseeach v3.0.4 | ||
# lodash._baseeach v4.0.0 | ||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) internal `baseEach` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
The internal [lodash](https://lodash.com/) function `baseEach` 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 baseEach = require('lodash._baseeach'); | ||
See the [package source](https://github.com/lodash/lodash/blob/3.0.4-npm-packages/lodash._baseeach) for more details. | ||
See the [package source](https://github.com/lodash/lodash/blob/4.0.0-npm-packages/lodash._baseeach) 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
9545
235
19
+ Addedlodash.keys@4.2.0(transitive)
- Removedlodash._getnative@3.9.1(transitive)
- Removedlodash.isarguments@3.1.0(transitive)
- Removedlodash.isarray@3.0.4(transitive)
- Removedlodash.keys@3.1.2(transitive)
Updatedlodash.keys@^4.0.0