Replies: 1 comment
-
Hey @Uzlopak, I've had a look at that library. With regard to typings, I had to write them for my library completely independently of the code itself as TypeScript wasn't able to infer everything based purely off simple function signatures. My code base ended up being more types than actual implementation code. You'll probably need to do a similar thing if you want to get your types right. (Though you can always just take a more simple approach like this: v4_0.d.ts) However getting the types right for the case when users pass in custom configuration data, specifically custom functions, was a real challenge. I managed to eventually get something working with the help of HKTs of the same implementation as fp-ts's HKT. If you're going to add support for this sort of thing to you're library then I wish you luck. With regards to the implementation itself, you code seems fine but I would recommend adding an option to not clone data and instead just use it as is. There are many use cases where users may want the leaves to the trees to be left alone. This will also end up speeding up your implementation as there is less work for the library to do. In my library, I don't even give an option for users to clone data; if they want that then need to integrate a deep clone library of their choice in with this library (using I'm not sure if there is anything I can really take out of your library an integrate here as the two take different approaches. I believe the main reason why yours is much faster is because it is making assumptions about the inputs (such as it's not going to be some |
Beta Was this translation helpful? Give feedback.
-
Hi @RebeccaStevens
I also reimplemented deepmerge at fastify/deepmerge. It is much faster than the original deepmerge. It lacks the support of merging Sets and Maps, but maybe you have some thoughts about the implementation or the typings. Maybe you also want to improve the performance of your implementation and modify your code depending on it.
Beta Was this translation helpful? Give feedback.
All reactions