0.0.1 • Published 7 years ago

u-each v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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