Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
immutable-set
Advanced tools
Set nested properties of an object while respecting the principles of immutability
This tools aims to facilitate the modification of nested property while preserving immutable principles. Lets say you have the given object:
const state = {
a: {
foo: 'bar',
},
b: {
value: 3,
},
};
If we want to increment b.value
, immutability says that we should generate a new object where
newState === state // false
newState.b === state.b // false
newState.a === state.a // true
That exactly what does our set
function,
Add the dependency to your project:
yarn add immutable-set
name | description | type |
---|---|---|
base | object to modify | object |
path | list of keys to access the value to being modified | array |
value | value to set | any |
withArray (optional) | if set to true number will be interpreted has array indexes | boolean |
Import set
function
import set from 'immutable-set';
Then set the property you want in your object
const newState = set(state, ['a', 0, 'b'], 42, true);
/*
newState => {
a: [
{
b: 42,
},
],
...
}
*/
FAQs
Set nested properties of an object while respecting the principles of immutability
The npm package immutable-set receives a total of 747 weekly downloads. As such, immutable-set popularity was classified as not popular.
We found that immutable-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.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.