Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
deep-props.set
Advanced tools
Sets values within nested objects; creates structure if not found. Supports setting within Objects, Arrays, Maps, Sets, WeakMaps, and WeakSets; supports creation of Objects, Arrays, and Maps.
Sets values within nested objects; creates structure if not found. Supports setting within Objects, Arrays, Maps, Sets, WeakMaps, and WeakSets; supports creation of Objects, Arrays, and Maps.
See the usage examples for an overview of different types of data structures.
The following installation, testing, and deployment instructions assume that deep-props.set will be installed as a standalone module. For instructions on how to install and test all deep-props modules, please refer to the main README. Functionality of the module remains the same in both cases.
Node.JS version 8.7.0 or above.
npm install deep-props.set
The following command will test the package for errors. It prints a selection of examples to the console; scroll through its output if you want to learn more about the utility.
npm test --prefix /path/to/node_modules/deep-props.set
const set = require('deep-props.set')
Note: For string paths using standard settings, '.' is considered the same as '[' and ']'. See Options
for instructions for customizing this behavior.
Setting within existing Object structure
const nest = { foo: { bar: { baz: 'beh' } } }
// Both return: { foo: { bar: { baz: 'qux' } } }
set(nest, 'foo.bar.baz', 'qux')
nest
Setting within existing Array structure
const nest = [[['foo']]]
// Both return: [[['bar']]]
set(nest, '0.0.0', 'bar')
nest
Setting within existing Map structure
const nest = new Map().set(
'foo', new Map().set(
'bar', new Map().set(
'baz', 'beh'
)
)
)
// Both return: Map { 'foo' => Map { 'bar' => Map { 'baz' => 'qux' } } }
set(nest, 'foo.bar.baz', 'qux')
nest
Setting within existing Set structure
const nest = new Set([
new Set([
new Set([
'foo'
])
])
])
// Both return: Set { Set { Set { 'bar' } } }
set(nest, '0.0.0', 'bar')
nest
// Both return: Set { Set { Set { 'bar', 'baz' } } }
set(nest, '0.0.1', 'baz')
nest
Creation of new Object structure
const nest = {}
// Both return: { foo: { bar: { baz: 'qux' } } }
set(nest, 'foo.bar.baz', 'qux')
nest
Creation of new Array structure
const nest = []
// Both return: [[['foo']]]
set(nest, '0.0.0', 'foo')
nest
Creation of new Map structure
const nest = new Map()
// Both return: Map { ['foo'] => Map { ['bar'] => Map { ['baz'] => 'beh' } } }
set(nest, [['foo'], ['bar'], ['baz']], 'beh')
nest
Sets values within nested objects; creates structure if not found. Supports setting within Objects, Arrays, Maps, Sets, WeakMaps, and WeakSets; supports creation of Objects, Arrays, and Maps.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
host | deep-props.set~Host | Container to search within. | ||
path | deep-props.set~Path | Path to desired property. | ||
data | * | Data to set at endpoint of path. | ||
opt | deep-props.set~Options | <optional> | {} | Execution settings. |
Source:
True if successful, false if not. If opt.gen === true
, returns a generator that yields each search step.
Type
boolean | deep-props.set~ResultGenerator
Versioned using SemVer. For available versions, see the Changelog.
Please raise an issue if you find any. Pull requests are welcome!
This project is licensed under the MIT License - see the LICENSE file for details
FAQs
Sets values within nested objects; creates structure if not found. Supports setting within Objects, Arrays, Maps, Sets, WeakMaps, and WeakSets; supports creation of Objects, Arrays, and Maps.
We found that deep-props.set demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.