1.0.0 • Published 6 years ago

some-own v1.0.0

Weekly downloads
4
License
CC0-1.0
Repository
github
Last release
6 years ago

some-own

Like [].some but for objects.

npm install some-own
const someOwn = require("some-own")

API

someOwn(object, callback, scope: undefined)

@param

  • object is the object to iterate
  • callback receives (value, key, object)
  • scope is the this context used to .call callback

@return boolean

  • Breaks from the loop and returns true if any callback iteration result returns truthy
  • Else returns false

Usage

const someOwn = require("some-own")
someOwn({x: 5, y: 0}, value => value < 0) // false
someOwn({x: -5, y: 0}, value => value < 0) // true
someOwn({x: 5, y: 0}, (value, key) => key.length === 1) // true
let array = []
someOwn({x: 5, y: 0}, value => array.push(value)) // true
array.length // 1
let array = []
someOwn({x: 5, y: 0}, value => array.push(value) > 10) // false
array.length // 2