1.0.0 • Published 6 years ago

prop-entries v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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

  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” 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

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.