@yodata/has-value

0.0.3 • Public • Published

@yodata/has-value

checks an object for a value by keyname or path in dot notation returns true if the key exists with optional comparator value or function

example

const has = require('@yodata/has-value')
const object = { a: { b: 1 }}
has(object, 'a.b') // returns true
has(object, 'a.c') // returns false

// optional comparator values

has(object, 'a.b',1) // returns true
has(object, 'a.b',2) // returns false

// optional comparator function
const comparator = (value) => { return (typeof value === 'number' && value > 1) }
has(object,'a.b', comparator) // returns false

Readme

Keywords

none

Package Sidebar

Install

npm i @yodata/has-value

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

4.4 kB

Total Files

5

Last publish

Collaborators

  • cvraghu
  • yodaveduran