https://github.com/lamansky/prop-entries
[Node.js] Returns an array of all properties (owned and inherited) of an object.
https://github.com/lamansky/prop-entries
Last synced: 3 months ago
JSON representation
[Node.js] Returns an array of all properties (owned and inherited) of an object.
- Host: GitHub
- URL: https://github.com/lamansky/prop-entries
- Owner: lamansky
- License: mit
- Created: 2018-05-23T14:14:59.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-23T14:16:00.000Z (about 8 years ago)
- Last Synced: 2025-10-30T03:51:56.165Z (8 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
# prop-entries
Returns an array of all properties (owned and inherited) of an object.
## Installation
Requires [Node.js](https://nodejs.org/) 7.0.0 or above.
```bash
npm i prop-entries
```
## API
The module exports a single function.
### Parameters
1. Bindable: `obj` (object): The object whose properties you want to get.
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 returned. 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 returned.
### Return Value
An array of two-element key-value-pair arrays.
## Example
```javascript
const props = require('prop-entries')
props({key: 'value'}, {own: true}) // [['key', 'value']]
```
## Related
* [prop-keys](https://github.com/lamansky/prop-keys): Same as this module, except it returns only keys.
* [prop-values](https://github.com/lamansky/prop-values): Same as this module, except it returns only values.
* [entries-array](https://github.com/lamansky/entries-array): Supports more than just Objects.