prop-entries
v1.0.0
Published
Returns an array of all properties (owned and inherited) of an object.
Downloads
19
Maintainers
Readme
prop-entries
Returns an array of all properties (owned and inherited) of an object.
Installation
Requires Node.js 7.0.0 or above.
npm i prop-entries
API
The module exports a single function.
Parameters
- Bindable:
obj
(object): The object whose properties you want to get. - Object argument:
- Optional:
own
(boolean): If set totrue
, only the object’s “own” properties are returned. 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 returned.
- Optional:
Return Value
An array of two-element key-value-pair arrays.
Example
const props = require('prop-entries')
props({key: 'value'}, {own: true}) // [['key', 'value']]
Related
- prop-keys: Same as this module, except it returns only keys.
- prop-values: Same as this module, except it returns only values.
- entries-array: Supports more than just Objects.