objectkeys
To get all the keys of an object. It provides options to fetch nested keys as well.
Installation
Install with npm:
$ npm install objectkeys --save
Usage
var OBJECT_KEYS = ; var object = 'California' : 'CA' 'Texas' : 'TX' 'NEW YORK' : 'NY' ; OBJECT_KEYS;//=> ['California', 'Texas', 'NEW YORK'] var days = 'SUNDAY' : 'First' 'MONDAY' : 'Second' 'TUESDAY' : 'Third' 'WEDNESDAY' : 3; OBJECT_KEYS;//=> ['SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY']
Clone the repo
$ git clone https://github.com/luthraG/objectkeys.git
API
keys(obj, [options])
This API takes two parameters:
- Object whose keys to be fetched and
- options object. This argument is optional
Options
Various options supported by this API are :
- deep - To specify if nested keys should also be fethced. Default is false.
Example with options
var OBJECT_KEYS = ; var days = 'SUNDAY' : 'First' 'MONDAY' : 'Second' 'TUESDAY' : 'Third' 'WEDNESDAY' : 3 'WEEK_END' : 'SUNDAY' : 'CODE' : 'ABBR' : 'SAT' ; OBJECT_KEYS;//=> [ 'SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'WEEK_END', 'SUNDAY', 'CODE', 'ABBR' ]
Related projects
You might also be interested in these projects:
- objectvalues: To get all the values of all the keys of an object. It provides options to fetch values of nested keys as well. | homepage
- uppercase-values: Convert the values of all the keys of an object into uppercase. | homepage
- lowercase-values: Convert the values of all the keys of an object into lowercase. | homepage
- object-lowerkeys: Convert the keys of an object into lowercase. | homepage
- object-upperkeys: Convert the keys of an object into uppercase. | homepage
Author
Gaurav Luthra
License
MIT © Gaurav Luthra