Sensible wrapper for Object.assign()
.
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/
npm install safe-object-assign
OR
git clone https://github.com/dfkaye/safer-object-assign.git
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/.