Our great sponsors
-
mutative
Efficient immutable updates, 2-6x faster than naive handcrafted reducer, and more than 10x faster than Immer.
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
limu
High performance immutable lib alternative to immer with the same api, based on shallow copy on read and mark modified on write mechanism.
-
proposal-record-tuple
ECMAScript proposal for the Record and Tuple value types. | Stage 2: it will change!
-
superjson
Safely serialize JavaScript expressions to a superset of JSON, which includes Dates, BigInts, and more.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
A lot of Lodash functions are implemented as combinations of other Lodash functions, so importing a single function actually imports half of Lodash under the hood:
https://github.com/lodash/lodash/blob/main/src/.internal/bas...
for those recommending Immer, check out Mutative or Limu instead (much faster)
https://github.com/unadlib/mutative
https://github.com/tnfe/limu
for those recommending Immer, check out Mutative or Limu instead (much faster)
https://github.com/unadlib/mutative
https://github.com/tnfe/limu
If you’re reaching for structuredClone, what you really want is native immutable Record and Tuple syntax, and the companion “deep path properties” syntax which allows for efficient and ergonomic immutable updates:
- https://github.com/tc39/proposal-record-tuple
I wasn't aware of this, I would like to give a shout out to superjson (https://github.com/blitz-js/superjson) which I had been using to solve this problem. I will look at this solution for next time.
Instead of the "deep path properties" syntax, you might want to take the opportunity to learn about functional lenses with monocle-ts
https://gcanti.github.io/monocle-ts/
Related posts
- Ramda: A practical functional library for JavaScript programmers
- I created a CLI tool that writes unit tests with GPT-4 (with one command, I created tests for Lodash repo with 90% code coverage and found 13 bugs)
- Why doesn't TypeScript properly type Object.keys?
- TypeScript is 'not worth it' for developing libraries, says Svelte author, as team switches to JavaScript and JSDoc
- FP and JavaScript/TypeScript