https://github.com/dfkaye/safe-object-assign
Sensible wrapper for Object.assign()
https://github.com/dfkaye/safe-object-assign
Last synced: 3 months ago
JSON representation
Sensible wrapper for Object.assign()
- Host: GitHub
- URL: https://github.com/dfkaye/safe-object-assign
- Owner: dfkaye
- License: mit
- Created: 2020-11-19T04:28:47.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-20T21:02:26.000Z (over 4 years ago)
- Last Synced: 2024-04-25T09:41:31.994Z (about 1 year ago)
- Language: JavaScript
- Size: 28.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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,
1. without blowing up,
2. retain the initial value if it is not an object or array,
3. obtain a modified copy of the initial object or array to be updated,
4. 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/.