/object-dot-keys

🌳 Create an array of keys paths from an object.

Primary LanguageJavaScriptISC LicenseISC

object-dot-keys

🌳 Create an array of key paths from an object.

NPM version Build StatusCode Coverage 100%ISC LicenseNodeJS

API

import objectDotKeys from 'object-dot-keys';

objectDotKeys({}, 'separator');

Usage

  import objectDotKeys from 'object-dot-keys';

  const obj = {
    a: { b: 'c' },
    b: [{ c: 'a' }, { c: 'b' }, { c: 'c' }]
  };

  objectDotKeys(obj) // ['a.b', 'b.0.c', 'b.1.c', 'b.2.c']
  objectDotKeys(obj, { separator: '_' });  // ['a_b', 'b_0_c', 'b_1_c', 'b_2_c']
  objectDotKeys(obj, { array: false });  // ['a.b', 'b']