Gathering detailed insights and metrics for object-path-immutable-yolo
Gathering detailed insights and metrics for object-path-immutable-yolo
Gathering detailed insights and metrics for object-path-immutable-yolo
Gathering detailed insights and metrics for object-path-immutable-yolo
Modify deep object properties without modifying the original object (immutability). Works great with React and Redux.
npm install object-path-immutable-yolo
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
416 Stars
117 Commits
47 Forks
8 Watchers
9 Branches
24 Contributors
Updated on Jul 14, 2025
Latest Version
0.5.1
Package Id
object-path-immutable-yolo@0.5.1
Size
20.72 kB
NPM Version
4.2.0
Node Version
7.10.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Tiny JS library to modify deep object properties without modifying the original object (immutability).
Works great with React (especially when using setState()
) and Redux (inside a reducer).
This can be seen as a simpler and more intuitive alternative to the React Immutability Helpers and Immutable.js.
npm install object-path-immutable --save
The following, sets a property without modifying the original object.
It will minimize the number of clones down the line. The resulting object is just a plain JS object literal,
so be warned that it will not be protected against property mutations (like Immutable.js
)
1const obj = { 2 a: { 3 b: 'c', 4 c: ['d', 'f'] 5 } 6} 7 8const newObj = immutable.set(obj, 'a.b', 'f') 9// { 10// a: { 11// b: 'f', 12// c: ['d', 'f'] 13// } 14// } 15 16// obj !== newObj 17// obj.a !== newObj.a 18// obj.b !== newObj.b 19 20// However: 21// obj.c === newObj.c
Note that you can also chain the api's and call value()
at the end to retrieve the resulting object.
1const newObj = immutable(obj).set('a.b', 'f').del('a.c.0').value()
1// Premises 2 3const obj = { 4 a: { 5 b: 'c', 6 c: ['d', 'f'] 7 } 8} 9 10import immutable from 'object-path-immutable'
Changes an object property.
1const newObj1 = immutable.set(obj, 'a.b', 'f') 2const newObj2 = immutable.set(obj, ['a', 'b'], 'f') 3const newObj3 = immutable.set(obj, ['a', 'b'], v => 'f') 4 5// { 6// a: { 7// b: 'f', 8// c: ['d', 'f'] 9// } 10// } 11 12// Note that if the path is specified as a string, numbers are automatically interpreted as array indexes. 13 14const newObj = immutable.set(obj, 'a.c.1', 'fooo') 15// { 16// a: { 17// b: 'f', 18// c: ['d', 'fooo'] 19// } 20// }
Push into a deep array (it will create intermediate objects/arrays if necessary).
1const newObj = immutable.push(obj, 'a.d', 'f') 2// { 3// a: { 4// b: 'f', 5// c: ['d', 'f'], 6// d: ['f'] 7// } 8// }
Deletes a property.
1const newObj = immutable.del(obj, 'a.c') 2// { 3// a: { 4// b: 'f' 5// } 6// }
Can also delete a deep array item using splice
1const newObj = immutable.del(obj, 'a.c.0') 2// { 3// a: { 4// b: 'f', 5// c: ['f'] 6// } 7// }
Shallow copy properties.
1const newObj = immutable.assign(obj, 'a', { b: 'f', g: 'h' }) 2// { 3// a: { 4// b: 'f', 5// c: ['d, 'f'], 6// g: 'h' 7// } 8// }
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
Found 6/25 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
24 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More