safe-object-assign
v0.0.11
Published
Make Object.assign() safer for values and objects.
Downloads
8
Readme
safe-object-assign
Sensible wrapper for Object.assign()
.
Documentation
Object.assign()
can return surprising results when a value to be modified is not an object.
The point of safe-object-assign
is to allow users to pass anything,
- without blowing up,
- retain the initial value if it is not an object or array,
- obtain a modified copy of the initial object or array to be updated,
- mixing only objects or arrays into the new model.
See full details on my blog post at https://dfkaye.com/posts/2020/08/21/safer-object.assign-operations-using-a-sensible-wrapper/
Install
npm install safe-object-assign
OR
git clone https://github.com/dfkaye/safer-object-assign.git
Test
Install dependencies (mocha and chai): npm install safe-object-assign --save-dev
Run: npm test
OR
Visit the live demo running the browser test suite on my blog: https://dfkaye.com/demos/safe-assign-test-suite/.