props-iterator
Iterates all properties (owned and inherited) of an object.
Installation
Requires Node.js 7.0.0 or above.
npm i props-iterator
API
The module exports a single function.
Parameters
- Bindable:
obj
(object): The object whose properties you want to iterate. - Object argument:
- Optional:
own
(boolean): If set totrue
, only the object’s “own” properties are iterated. If omitted or if set tofalse
, both owned and inherited properties are returned. - Optional:
enumOnly
(boolean): If set totrue
, only properties defined with theenumerable
flag will be iterated.
- Optional:
Return Value
An iterator that yields two-element key-value-pair arrays.
Example
const props = const iter = iternextvalue // ['key', 'value']iternextdone // true
Related
- prop-entries: Same as this module, except it returns an array.
- entries-iterator: Supports more than just Objects.