Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dhas

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dhas

Safe deep property checking

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

dhas Build Status

Check whether an object owns deep properties

Why

Super small implementation — only 160 bytes!

You could write this yourself, but then you'd have to write tests.

Supports ES Modules, CommonJS and UMD.

Installation

npm install dhas

Usage

import dhas from 'dhas';
const object = { a: { b: { c: null, d: undefined, e: 'string' } } };

// returns true even for null and undefined values
dhas(object, 'a.b.c'); // true
dhas(object, 'a.b.d'); // true

// first argument can be an object OR an array
dhas(object, 'a.b'); // true
dhas([0,1,2,3], '0'); // true

// second paramter can be a string (delineated by dots) OR an array of strings
dhas(object, 'a.b.c'); // true
dhas(object, ['a', 'b', 'c']); // true

Similar libraries

For getting deep object properties, check out dlv For setting deep object properties, check out dset

This library was heavily inspired by both!

License

MIT

FAQs

Package last updated on 23 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc