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

bubble-gum-set

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

bubble-gum-set

Sets a new value in a nested object or a nested array using an array path, if the path does not exist create this

latest
Source
npmnpm
Version
0.0.10
Version published
Maintainers
1
Created
Source

bubble-gum-set

Sets a new value in a nested object or a nested array using an array path, if the path does not exist create this

bubble-gum-set is part of bubble-gum-tools, check this here

Install

You can install bubble-gum-set using npm.

npm install --save bubble-gum-set

API Reference

bubble-gum-set

module.exports(target, path, valueToSet) ⏏

It sets a new value in a nested object or a nested array using an array path, if the path does not exist create this

Kind: Exported function

ParamTypeDescription
targetObject | ArrayTarget object or target array
pathArrayPath to property
valueToSet*Value to set in target

Example


const set = require('bubble-gum-set');

const target = {
  root: {
    foo: 'bar',
  },
  arr: [[
    ['baz'],
  ]],
};

set(target, ['root', 'foo'], 'newbar');
console.log(target.root.foo); // => 'newbar'

set(target, ['arr', 0, 0, 0], 'newbaz');
console.log(target.arr[0][0][0]); // => 'newbaz'

set(target, ['root', 'foo2'], 'foo2');
console.log(target.root.foo2); // => 'foo2'

set(target, ['arr', 0, 0, 1], 'newbaz2');
console.log(target.arr[0][0][1]); // => 'newbaz2'

License

MIT @ Nicolas Quiceno

Keywords

nested-objects

FAQs

Package last updated on 29 Mar 2017

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