New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

dynamic-props

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynamic-props

Set and delete nested properties

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

dynamic-props

dynamic-props allows to create and delete nested properties of object literals dynamically.

Usage

import { setNestedProp } from 'dynamic-props';

const foo = {};

setNestedProp`bar.baz[${2}].qux`(foo, 'hello');

console.log(foo);

{ bar: { baz: [ <2 empty items>, { qux: 'hello' } ] } }

import { deleteNestedProp } from 'dynamic-props';

deleteNestedProp`bar.baz[${2}].qux`(foo);

console.log(foo);

{ }

Note that by default deleteNestedProp recursively removes properties containing undefined values, empty objects, empty arrays or arrays containing only undefined values.

Limitations

Multidimensional arrays are not supported.

Installation

You can get dynamic-props via npm.

$ npm install dynamic-props --save

Keywords

dynamic props

FAQs

Package last updated on 30 Jan 2022

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