just-has
TypeScript icon, indicating that this package has built-in type declarations

2.3.0 • Public • Published

just-has

Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.

🍦 Try it

npm install just-has
yarn add just-has

Return a boolen indicating the existence of a deep property, don't throw if parent is undefined

import has from 'just-has';

const obj = {a: {aa: {aaa: 2}}, b: 4};

has(obj, 'a.aa.aaa'); // true
has(obj, ['a', 'aa', 'aaa']); // true

has(obj, 'b.bb.bbb'); // false
has(obj, ['b', 'bb', 'bbb']); // false

has(obj.a, 'aa.aaa'); // true
has(obj.a, ['aa', 'aaa']); // true

has(obj.b, 'bb.bbb'); // false
has(obj.b, ['bb', 'bbb']); // false

has(null, 'a'); // false
has(undefined, ['a']); // false

const obj = {a: {}};
const sym = Symbol();
obj.a[sym] = 4;
has(obj.a, sym); // true

Dependents (6)

Package Sidebar

Install

npm i just-has

Weekly Downloads

7,592

Version

2.3.0

License

MIT

Unpacked Size

6.42 kB

Total Files

9

Last publish

Collaborators

  • angus-c