https://github.com/ryanve/some-own
JavaScript someOwn function
https://github.com/ryanve/some-own
javascript opensource
Last synced: 11 months ago
JSON representation
JavaScript someOwn function
- Host: GitHub
- URL: https://github.com/ryanve/some-own
- Owner: ryanve
- License: other
- Created: 2017-12-09T19:11:15.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-22T01:34:13.000Z (over 7 years ago)
- Last Synced: 2025-08-08T08:02:05.444Z (11 months ago)
- Topics: javascript, opensource
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/some-own
- Size: 13.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# [`some-own`](https://www.npmjs.com/package/some-own)
Like `[].some` but for objects.
```
npm install some-own
```
```js
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
```js
const someOwn = require("some-own")
```
```js
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
```
```js
let array = []
someOwn({x: 5, y: 0}, value => array.push(value)) // true
array.length // 1
```
```js
let array = []
someOwn({x: 5, y: 0}, value => array.push(value) > 10) // false
array.length // 2
```
## BFF
[`every-own`](https://www.npmjs.com/package/every-own)