Skip to content

Recursively builds a tree of object keys. Useful for creating lists or debugging.

License

Notifications You must be signed in to change notification settings

jonschlinkert/keys-tree

Repository files navigation

keys-tree NPM version Build Status

Recursively builds a tree of object keys. Useful for creating lists or debugging.

Install with npm

npm i keys-tree --save

Usage

var keys = require('keys-tree');

keys({a: 'b', c: 'd'});
//=> { keys: [ 'a', 'c' ] }

keys({a: 'b', c: {d: 'e', f: 'g'}});
//=> { keys: [ 'a', 'c' ], c: { keys: [ 'd', 'f' ] } }

keys({a: 'b', c: {d: 'e', f: 'g', h: {i: 'j', k: 'l', m: 'n'}}});
// results in:
// { keys: [ 'a', 'c' ], 
//   c: { keys: [ 'd', 'f', 'h' ], 
//        h: { keys: [ 'i', 'k', 'm' ] } } }

Other object utils

  • stringify-keys: Build an array of key paths from an object.
  • rename-keys: Modify the names of the own enumerable properties (keys) of an object.
  • get-value: Use property paths (a.b.c) get a nested value from an object.
  • set-object: Create nested objects and any intermediaries using a.b.c paths.

Running tests

Install dev dependencies.

npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb-cli on March 22, 2015.

About

Recursively builds a tree of object keys. Useful for creating lists or debugging.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published