lodash.foreach
Advanced tools
Comparing version 2.4.1 to 3.0.0
61
index.js
/** | ||
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> | ||
* Build: `lodash modularize modern exports="npm" -o ./npm/` | ||
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> | ||
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Available under MIT license <http://lodash.com/license> | ||
* lodash 3.0.0 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modern modularize exports="npm" -o ./` | ||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Available under MIT license <https://lodash.com/license> | ||
*/ | ||
var baseCreateCallback = require('lodash._basecreatecallback'), | ||
forOwn = require('lodash.forown'); | ||
var arrayEach = require('lodash._arrayeach'), | ||
baseEach = require('lodash._baseeach'), | ||
bindCallback = require('lodash._bindcallback'), | ||
isArray = require('lodash.isarray'); | ||
/** | ||
* Iterates over elements of a collection, executing the callback for each | ||
* element. The callback is bound to `thisArg` and invoked with three arguments; | ||
* (value, index|key, collection). Callbacks may exit iteration early by | ||
* explicitly returning `false`. | ||
* Iterates over elements of `collection` invoking `iteratee` for each element. | ||
* The `iteratee` is bound to `thisArg` and invoked with three arguments; | ||
* (value, index|key, collection). Iterator functions may exit iteration early | ||
* by explicitly returning `false`. | ||
* | ||
* Note: As with other "Collections" methods, objects with a `length` property | ||
* **Note:** As with other "Collections" methods, objects with a `length` property | ||
* are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn` | ||
@@ -25,32 +27,21 @@ * may be used for object iteration. | ||
* @alias each | ||
* @category Collections | ||
* @category Collection | ||
* @param {Array|Object|string} collection The collection to iterate over. | ||
* @param {Function} [callback=identity] The function called per iteration. | ||
* @param {*} [thisArg] The `this` binding of `callback`. | ||
* @param {Function} [iteratee=_.identity] The function invoked per iteration. | ||
* @param {*} [thisArg] The `this` binding of `iteratee`. | ||
* @returns {Array|Object|string} Returns `collection`. | ||
* @example | ||
* | ||
* _([1, 2, 3]).forEach(function(num) { console.log(num); }).join(','); | ||
* // => logs each number and returns '1,2,3' | ||
* _([1, 2, 3]).forEach(function(n) { console.log(n); }); | ||
* // => logs each value from left to right and returns the array | ||
* | ||
* _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); | ||
* // => logs each number and returns the object (property order is not guaranteed across environments) | ||
* _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, key); }); | ||
* // => logs each value-key pair and returns the object (iteration order is not guaranteed) | ||
*/ | ||
function forEach(collection, callback, thisArg) { | ||
var index = -1, | ||
length = collection ? collection.length : 0; | ||
callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); | ||
if (typeof length == 'number') { | ||
while (++index < length) { | ||
if (callback(collection[index], index, collection) === false) { | ||
break; | ||
} | ||
} | ||
} else { | ||
forOwn(collection, callback); | ||
} | ||
return collection; | ||
function forEach(collection, iteratee, thisArg) { | ||
return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) | ||
? arrayEach(collection, iteratee) | ||
: baseEach(collection, bindCallback(iteratee, thisArg, 3)); | ||
} | ||
module.exports = forEach; |
@@ -1,3 +0,3 @@ | ||
Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> | ||
Based on Underscore.js 1.5.2, copyright 2009-2013 Jeremy Ashkenas, | ||
Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, | ||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> | ||
@@ -22,2 +22,2 @@ | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
{ | ||
"name": "lodash.foreach", | ||
"version": "2.4.1", | ||
"description": "The Lo-Dash function `_.forEach` as a Node.js module generated by lodash-cli.", | ||
"homepage": "http://lodash.com/custom-builds", | ||
"version": "3.0.0", | ||
"description": "The modern build of lodash’s `_.forEach` as a module.", | ||
"homepage": "https://lodash.com/", | ||
"icon": "https://lodash.com/icon.svg", | ||
"license": "MIT", | ||
"keywords": ["functional", "lodash", "lodash-modularized", "server", "util"], | ||
"keywords": "lodash, lodash-modularized, stdlib, util", | ||
"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/)", | ||
"Mathias Bynens <mathias@qiwi.be> (http://mathiasbynens.be/)" | ||
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)" | ||
], | ||
"bugs": "https://github.com/lodash/lodash-cli/issues", | ||
"repository": { "type": "git", "url": "https://github.com/lodash/lodash-cli.git" }, | ||
"repository": "lodash/lodash", | ||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" }, | ||
"dependencies": { | ||
"lodash._basecreatecallback": "~2.4.1", | ||
"lodash.forown": "~2.4.1" | ||
"lodash._arrayeach": "^3.0.0", | ||
"lodash._baseeach": "^3.0.0", | ||
"lodash._bindcallback": "^3.0.0", | ||
"lodash.isarray": "^3.0.0" | ||
} | ||
} |
@@ -1,15 +0,20 @@ | ||
# lodash.foreach v2.4.1 | ||
# lodash.foreach v3.0.0 | ||
The [Lo-Dash](http://lodash.com/) function [`_.forEach`](http://lodash.com/docs#forEach) as a [Node.js](http://nodejs.org/) module generated by [lodash-cli](https://npmjs.org/package/lodash-cli). | ||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.forEach` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
## Author | ||
## Installation | ||
| [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter") | | ||
|---| | ||
| [John-David Dalton](http://allyoucanleet.com/) | | ||
Using npm: | ||
## Contributors | ||
```bash | ||
$ {sudo -H} npm i -g npm | ||
$ npm i --save lodash.foreach | ||
``` | ||
| [![twitter/blainebublitz](http://gravatar.com/avatar/ac1c67fd906c9fecd823ce302283b4c1?s=70)](https://twitter.com/blainebublitz "Follow @BlaineBublitz on Twitter") | [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge "Follow @kitcambridge on Twitter") | [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") | | ||
|---|---|---| | ||
| [Blaine Bublitz](http://www.iceddev.com/) | [Kit Cambridge](http://kitcambridge.be/) | [Mathias Bynens](http://mathiasbynens.be/) | | ||
In Node.js/io.js: | ||
```js | ||
var forEach = require('lodash.foreach'); | ||
``` | ||
See the [documentation](https://lodash.com/docs#forEach) or [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash.foreach) 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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
21
4872
4
44
1
+ Addedlodash._arrayeach@^3.0.0
+ Addedlodash._baseeach@^3.0.0
+ Addedlodash._bindcallback@^3.0.0
+ Addedlodash.isarray@^3.0.0
+ Addedlodash._arrayeach@3.0.0(transitive)
+ Addedlodash._baseeach@3.0.4(transitive)
+ Addedlodash._bindcallback@3.0.1(transitive)
+ Addedlodash._getnative@3.9.1(transitive)
+ Addedlodash.isarguments@3.1.0(transitive)
+ Addedlodash.isarray@3.0.4(transitive)
+ Addedlodash.keys@3.1.2(transitive)
- Removedlodash._basecreatecallback@~2.4.1
- Removedlodash.forown@~2.4.1
- Removedlodash._basebind@2.4.1(transitive)
- Removedlodash._basecreate@2.4.1(transitive)
- Removedlodash._basecreatecallback@2.4.1(transitive)
- Removedlodash._basecreatewrapper@2.4.1(transitive)
- Removedlodash._createwrapper@2.4.1(transitive)
- Removedlodash._isnative@2.4.1(transitive)
- Removedlodash._objecttypes@2.4.1(transitive)
- Removedlodash._setbinddata@2.4.1(transitive)
- Removedlodash._shimkeys@2.4.1(transitive)
- Removedlodash._slice@2.4.1(transitive)
- Removedlodash.bind@2.4.1(transitive)
- Removedlodash.forown@2.4.1(transitive)
- Removedlodash.identity@2.4.1(transitive)
- Removedlodash.isfunction@2.4.1(transitive)
- Removedlodash.isobject@2.4.1(transitive)
- Removedlodash.keys@2.4.1(transitive)
- Removedlodash.noop@2.4.1(transitive)
- Removedlodash.support@2.4.1(transitive)