u-each
v0.0.1
Published
A uniform way to iterate over arrays and objects while preserving the ability to break the loop if needed
Downloads
4
Readme
u-each
A uniform way to iterate over arrays and objects while preserving the ability to break the loop if needed
Install
npm install --save u-each
Use
const each = require('u-each')
each([1, 2, 3], (item, index, arr) => {
if (item === 2) {
return 'break'
}
})
// no need to check hasOwnProperty
each({ one: 1, two: 2 }, (key, value, obj) => {
if (key === 'two') {
return 'break'
} else {
return 'continue'
}
})