Comments (7)
I dig it! Test duplication is no problem, but from an API perspective I'd prefer if this were an optional boolean passed to merge
to enable deep merging.
Would love to see a Pull Request for this. 👍
from seamless-immutable.
Ok! Instead of a boolean, what to you think about a mergeWith
function or similar that takes a config object first (which the normal merge can use under the covers) so more config can be added later if needed?
obj1.mergeWith({deep: true}, obj2);
I have a use case where I would like to supply a custom merger sometimes, that could fit into this strategy.
But if you don't like it I will do a PR with the boolean.
from seamless-immutable.
IMO it's usually nicer to have configs or optional flags as the last argument in a function and not the first.
from seamless-immutable.
@RangerMauve I agree in general, but if the With
in the function name is for merging with the config I think it is natural if the mandatory config is first. Especially if it is a merge with multiple objects like:
obj1.mergeWith({deep: true}, obj2, obj3, obj4, obj5);
But it doesn't matter much either way. Any thoughts @rtfeldman?
from seamless-immutable.
@crudh That's a good point, actually. And it'd work well once rest paramters become mainstream.
from seamless-immutable.
Good points all around. My preference is to change the existing merge
as follows:
- It now always takes exactly one or exactly two arguments.
- The first argument works the same as always: you can pass it one object to merge, or an array of them.
- The second argument is optional, and is a configuration object that currently supports only
{deep: true}
Sound good?
from seamless-immutable.
Sounds good to me!
from seamless-immutable.
Related Issues (20)
- Make `without` support removing item from an array HOT 4
- how to use splice like array HOT 1
- Internet Explorer tests are failing HOT 4
- Issue regarding null values HOT 5
- Why are IE tests failing? HOT 3
- How to apply splice with seamless-immutable? HOT 1
- Merge does not work with class instances
- __immutable_invariants_hold is enumerable on Edge HOT 1
- Garbage collector features? HOT 1
- Performance characteristics
- Any difference with deepCopy? HOT 1
- [types] Mixin not applied to nested objects HOT 1
- flatMap not working HOT 2
- Add documentation for merge mode
- Files not being replaced on a deep merge
- Fails on IE 11 HOT 1
- TypeError: Object(...) is not a function HOT 1
- Lodash Vulnerability Problem
- Is the project still maintained? HOT 2
- immutable object causes rapid memory growth HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from seamless-immutable.