Socket
Socket
Sign inDemoInstall

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~!


Version published
Weekly downloads
4.6M
increased by8.86%
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

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

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