Deep-search objects for keys in JavaScript objects. Keys can be searched by providing an array of keys, or using a dot-notiation.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

hasKeyDeep

Build Status

Deep-search objects for keys. Keys can be searched by providing an array of keys, or using a dot-notiation.

Examples

Complete application

hasKeyDeep({ a: { b: { c: 1 } } }, 'a.b.c') => true
hasKeyDeep({ a: { b: { c: 1 } } }, ['a', 'b', 'c']) => true
hasKeyDeep({ a: { b: { c: 1 } } }, 'a.b.c.d') => true
hasKeyDeep({ a: { b: { c: 1 } } }, 'a.c') => false
hasKeyDeep({}, 'a') => false

Partial application

var hasABC = hasKeyDeep('a.b.c');
hasAbc({a: { b: { c: 1 } } }) => true
hasAbc({a: 1 }) => false

Changelog

  • v2.1.4: Adds minor- and major-release NPM scripts
  • v2.1.3: Adds patch-release NPM script and adds project description
  • v2.1.1: Adds ESLint
  • v2.1.0: Adds support for null values (6/20/2016)
  • v2.0.0: Switches order of arguments, provides curried function if only one is supplied. (3/14/2016)
  • v1.0.1: Updates build status in README (3/3/2016)
  • v1.0.0: Adds argument validation; mocha tests (3/2/2016)
  • v0.0.3: Updated repository field in package.json (2/1/2015)
  • v0.0.2: Minor refactoring for better readability (1/22/2015)
  • v0.0.1: Initial release (1/22/2015)