https://github.com/lamansky/props-iterator
[Node.js] Iterates all properties (owned and inherited) of an object.
https://github.com/lamansky/props-iterator
Last synced: 3 months ago
JSON representation
[Node.js] Iterates all properties (owned and inherited) of an object.
- Host: GitHub
- URL: https://github.com/lamansky/props-iterator
- Owner: lamansky
- License: mit
- Created: 2018-03-06T15:09:15.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-23T14:21:25.000Z (about 8 years ago)
- Last Synced: 2025-11-27T09:33:23.331Z (7 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
# props-iterator
Iterates all properties (owned and inherited) of an object.
## Installation
Requires [Node.js](https://nodejs.org/) 7.0.0 or above.
```bash
npm i props-iterator
```
## API
The module exports a single function.
### Parameters
1. Bindable: `obj` (object): The object whose properties you want to iterate.
2. Object argument:
* Optional: `own` (boolean): If set to `true`, only the object’s “[own](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty)” properties are iterated. If omitted or if set to `false`, both owned and inherited properties are returned.
* Optional: `enumOnly` (boolean): If set to `true`, only properties defined with the `enumerable` flag will be iterated.
### Return Value
An iterator that yields two-element key-value-pair arrays.
## Example
```javascript
const props = require('props-iterator')
const iter = props({key: 'value'}, {own: true})
iter.next().value // ['key', 'value']
iter.next().done // true
```
## Related
* [prop-entries](https://github.com/lamansky/prop-entries): Same as this module, except it returns an array.
* [entries-iterator](https://github.com/lamansky/entries-iterator): Supports more than just Objects.