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

dlv

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dlv

Safely get a dot-notated property within an object.

  • 1.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created

What is dlv?

The dlv npm package is a safe deep property access utility. It allows you to access deeply nested properties within an object without the risk of throwing an error if a part of the path does not exist. It's particularly useful when dealing with complex data structures where some properties may be undefined or null.

What are dlv's main functionalities?

Safe property access

Access a deeply nested property without throwing if the path does not exist.

const dlv = require('dlv');
const obj = { a: { b: { c: 1 } } };
const value = dlv(obj, 'a.b.c'); // 1

Default value

Provide a default value if the deep property is undefined.

const dlv = require('dlv');
const obj = { a: { b: { } } };
const value = dlv(obj, 'a.b.c', 'default'); // 'default'

Access array indexes

Access an array index within a deeply nested structure.

const dlv = require('dlv');
const obj = { a: { b: [1, 2, 3] } };
const value = dlv(obj, ['a', 'b', 0]); // 1

Other packages similar to dlv

Keywords

FAQs

Package last updated on 22 May 2019

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