Skip to content

ryanve/some-own

Repository files navigation

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

BFF

every-own