https://github.com/quantizor/gentle-object-transformer
🤗 deep recursive transformation: make A into B while preserving the original object reference
https://github.com/quantizor/gentle-object-transformer
Last synced: 10 days ago
JSON representation
🤗 deep recursive transformation: make A into B while preserving the original object reference
- Host: GitHub
- URL: https://github.com/quantizor/gentle-object-transformer
- Owner: quantizor
- License: mit
- Created: 2014-11-22T01:59:15.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-22T02:09:23.000Z (over 10 years ago)
- Last Synced: 2025-03-06T15:51:32.435Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 117 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Gentle Object Transformer
=========================Walks through complex objects and transforms the destination into the source without outright replacement.
Useful for 2-way databound frameworks because it allows existing views to not be destroyed if they don't need to be.
1. Update matches between source and destination
2. Remove destination items not in source
3. Add source items not in destinationMatches array items based on properties ending in `_id` (change this to your ID syntax)
**NOTE** This uses some ES5 features like `Object.keys` and `Array.filter`. If you need it to work in browsers
older than IE9, I recommend either monkeypatching the prototypes or looking into a library like lodash.