oek

object-end-keys

get all end keys of object

Showing:

Popularity

Downloads/wk

40

GitHub Stars

4

Maintenance

Last Commit

5yrs ago

Contributors

3

Package

Dependencies

1

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

object-end-keys

Build Status Coverage Status

Install

npm i object-end-keys -S

Default options

var options = {
    separator: '.',
    keyType: {
        string: {
            prefix: '',
            suffix: ''
        },
        number: {
            prefix: '[',
            suffix: ']'
        }
    }
};

Usage example

var keys = require('object-end-keys');
var data = {
    "name": {
        "first": "Joseph",
        "last": "Raketov"
    },
    "age": 24,
    "eyeColor": "red",
    "friends": [
      {
        "id": 0,
        "name": "Alex Shakirov"
      }
    ]
};
Example 1: simple
keys(obj)
// ["name.first", "name.last", "age", "eyeColor", "friends[0].id", "friends[0].name"]
Example 2: includeParent
options = {
    includeParent: true
}

keys(obj, options)
// ["name", "name.first", "name.last", "age", "eyeColor", "friends", "friends[0]", "friends[0].id", "friends[0].name"]
Example 3: prefix/suffix of keyType
options = {
    keyType: {
        number: {
            prefix: '.',
            suffix: ''
        }
    }
};

keys(obj, options)
// ["name.first", "name.last", "age", "eyeColor", "friends.0.id", "friends.0.name"]

TODO:

  • support for browsers

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial