Deep Cloning Objects in JavaScript, the Modern Way

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • lodash

    A modern JavaScript utility library delivering modularity, performance, & extras.

  • 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...

  • mutative

    Efficient immutable updates, 2-6x faster than naive handcrafted reducer, and more than 10x faster than Immer.

  • for those recommending Immer, check out Mutative or Limu instead (much faster)

    https://github.com/unadlib/mutative

    https://github.com/tnfe/limu

  • 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.

    SurveyJS logo
  • limu

    High performance immutable lib alternative to immer with the same api, based on shallow copy on read and mark modified on write mechanism.

  • for those recommending Immer, check out Mutative or Limu instead (much faster)

    https://github.com/unadlib/mutative

    https://github.com/tnfe/limu

  • proposal-record-tuple

    ECMAScript proposal for the Record and Tuple value types. | Stage 2: it will change!

  • 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

  • LJSON

    JSON extended with pure functions.

  • superjson

    Safely serialize JavaScript expressions to a superset of JSON, which includes Dates, BigInts, and more.

  • 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.

  • 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.

    WorkOS logo
  • monocle-ts

    Functional optics: a (partial) porting of Scala monocle

  • 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/

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts