🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

dset

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dset

A tiny (194B) utility for safely writing deep Object values~!

3.1.4
latest
Source
npm
Version published
Weekly downloads
6.2M
0.07%
Maintainers
1
Weekly downloads
 
Created

What is dset?

The dset npm package is a tiny utility for safely setting deep values in JavaScript objects. It is designed to be fast and efficient, making it ideal for performance-sensitive applications.

What are dset's main functionalities?

Set deep values

This feature allows you to set a value deep within an object using a dot-separated string path. The dset function will create any necessary intermediate objects.

const dset = require('dset');
let obj = {};
dset(obj, 'a.b.c', 42);
console.log(obj); // { a: { b: { c: 42 } } }

Array index support

dset supports setting values within arrays by using bracket notation in the path string. This allows for complex nested structures involving both objects and arrays.

const dset = require('dset');
let obj = {};
dset(obj, 'a.b[0].c', 42);
console.log(obj); // { a: { b: [ { c: 42 } ] } }

Custom separator

You can specify a custom separator for the path string, allowing for flexibility in how paths are defined.

const dset = require('dset');
let obj = {};
dset(obj, 'a/b/c', 42, '/');
console.log(obj); // { a: { b: { c: 42 } } }

Other packages similar to dset

Keywords

deepset

FAQs

Package last updated on 09 Sep 2024

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