superjson
monocle-ts
Our great sponsors
superjson | monocle-ts | |
---|---|---|
9 | 7 | |
3,678 | 1,016 | |
8.7% | - | |
7.6 | 0.0 | |
4 months ago | over 1 year ago | |
TypeScript | TypeScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
superjson
-
Deep Cloning Objects in JavaScript, the Modern Way
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.
- Superjson β serialize JavaScript Dates, Maps, Sets to cross service boundaries
- GitHub - blitz-js/superjson: Safely serialize JavaScript expressions to a superset of JSON, which includes Dates, BigInts, and more.
- Superjson: Safely serialize JavaScript expressions to a superset of JSON
- Aplicativos da Web totalmente tipados
-
I've spent the whole day on this, but no luck, I wanna die :)
Here you go https://github.com/blitz-js/superjson
-
Rich on serialization
superjson has a plugin system and also supports ObjectId. https://github.com/blitz-js/superjson/pull/71
-
Prisma not working with next serversideprops
Hey Mahmoud from Prisma here ππΌ Next.js doesn't serialize the Date type. There are a couple of workarounds discussed in this GitHub discussion. Personally, I found that using superjson to be the simplest approach.
monocle-ts
-
Deep Cloning Objects in JavaScript, the Modern Way
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/
-
I may have a crush on the TypeScript compiler, because of stuff like this
You may be interested also in checking out the implementation of Lens in monocle-ts, one of the libraries in the fp-ts ecosystem
-
Haskell Lens Tutorial by Exercises
For anyone - anyone who's faffed around with JavaScript's spread syntax when working with nested immutable data, anyway - struggling to understand the general concept or utility of lenses, I'd encourage looking into monocle-ts. The motivation [0] that kicks off the README instantly made me a believer, and TypeScript's idiosyncratic type system makes using the library remarkably natural; it fits right in without needing to deal with anything analogous to Template Haskell.
[0] https://github.com/gcanti/monocle-ts#motivation
-
Is there a cleaner way to immutably update a deeply nested attribute? (I feel like this is not very clean)
You could have a look at the monocle-ts library. It was designed to deal with this kind of problem.
-
Simple Immutable Data w/ Spectacles π
spectacles-ts integrates seamlessly with the fp-ts ecosystem (it's built on top of the excellent monocle-ts library)
-
Why is it so difficult to modify a deeply nested state in React?
lenses help with this quite a bit, check out monocle-ts
-
You could have invented lenses!
You notice that Getters are composable as they are just pure functions, but the fact that setters are mutating values is not that nice. Tho, at this point we have invented quasi mutable lenses and If you really want you might invent actual purely functional lenses as well, but thatβs for another day. Meanwhile you can take a look at an actual typescript lesses library from @gcanti / monocle-ts.
What are some alternatives?
babel-plugin-superjson-next - Automatically transform your Next.js Pages to use SuperJSON
optics-ts - Type-safe, ergonomic, polymorphic optics for TypeScript
SurveyJS - Free Open-Source JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout that lets you load and run multiple web forms, or build your own self-hosted form management system, retaining all sensitive data on your servers. You have total freedom of choice as to the backend, because any server + database combination is fully compatible.
zustand - π» Bear necessities for state management in React
blitz-guard - Blitz Guard - The centralized permission based authorization for Blitz.js
spectacles-ts - Practical Optics β’ Unfancy monocle-ts
monarch-map
immutability-helper - mutate a copy of data without changing the original source
Prisma - Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
fp-ts-contrib - A community driven utility package for fp-ts
remix-routes - Typesafe routing for your Remix apps.
fp-ts - Functional programming in TypeScript