npm.io
0.0.1 • Published 9 years ago

u-each

Licence
MIT
Version
0.0.1
Deps
0
Vulns
0
Weekly
0

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'
  }
})