Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryanve/every-own
JavaScript everyOwn function
https://github.com/ryanve/every-own
javascript opensource
Last synced: about 1 month ago
JSON representation
JavaScript everyOwn function
- Host: GitHub
- URL: https://github.com/ryanve/every-own
- Owner: ryanve
- License: other
- Created: 2017-12-09T21:39:56.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-19T06:46:21.000Z (about 6 years ago)
- Last Synced: 2024-09-13T17:26:36.590Z (2 months ago)
- Topics: javascript, opensource
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/every-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
# [`every-own`](https://www.npmjs.com/package/every-own)
Like `[].every` but for objects.```
npm install every-own
``````js
const everyOwn = require("every-own")
```## API
### `everyOwn(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 `false` if any `callback` iteration result returns falsey
- Else returns `true`## Usage
```js
const everyOwn = require("every-own")
``````js
everyOwn({}, value => value > 0) // true
everyOwn({x: 3, y: 3}, value => value > 0) // true
everyOwn({x: -3, y: 3}, value => value > 0) // false
everyOwn({x: 3, y: 3}, (value, key) => key.length === 1) // true
``````js
let array = []
everyOwn({x: 3, y: 3}, value => array.push(value)) // true
array.length // 2
array.join("") // "33"
```## BFF
[`some-own`](https://www.npmjs.com/package/some-own)