A foreach that supports arrays and objects, provides the value and key/index, as well as break support on return false
- Install:
npm install --save foreach-elegant
- Module:
require('foreach-elegant')
- Install:
npm install --save foreach-elegant
- Module:
require('foreach-elegant')
- CDN URL:
//wzrd.in/bundle/foreach-elegant@2.0.1
- Install:
ender add foreach-elegant
- Module:
require('foreach-elegant')
This package is published with the following editions:
foreach-elegant
aliasesforeach-elegant/index.js
which uses Editions to automatically select the correct edition for the consumers environmentforeach-elegant/source/index.js
is Source + ESNext + Require + Flow Type Commentsforeach-elegant/es2015/index.js
is Babel Compiled + ES2015 + Require
Older environments may need Babel's Polyfill or something similar.
var foreach = require('foreach-elegant')
function iterator (value, key, list) {
console.log('received', key, '=', value, 'from', list)
if ( key === 'b' || value === 'y' ) {
console.log('ending iteration early')
return false
}
}
foreach({a:1, b:2, c:3}, iterator)
foreach(['x', 'y', 'z'], iterator)
foreach({a:1, c:3}, iterator)
foreach(['x', 'z'], iterator)
Discover the release history by heading on over to the HISTORY.md
file.
These amazing people are maintaining this project:
No sponsors yet! Will you be the first?
These amazing people have contributed code to this project:
Discover how you can contribute by heading on over to the CONTRIBUTING.md
file.
Unless stated otherwise all works are:
- Copyright © 2016+ Bevry Pty Ltd
and licensed under: