1.0.2 ā€¢ Published 5 years ago

get-by-dot v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

get-by-dot

šŸŒ³ Get value from object using dot path.

NPM version Build StatusCode Coverage 100%ISC LicenseNodeJS

API

import getByDot from 'get-by-dot';

getByDot({}, 'path');

Usage

  import getByDot from 'get-by-dot';

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

  getByDot(obj, 'a.b'); // c
  getByDot(obj, 'a'); // { b: 'c' }
  getByDot(obj, 'a.b.c'); // undefined
  getByDot(obj); // { a: { b: 'c' }, b: [{ c: 'a' }] };