produce
, asyncProduce
, and clone
function are just easier to call method, supported by Medium
class.
import { Medium } from "@sudoo/immutable";
const medium = Medium.from(object);
const newObject = medium.clone();
const newObject = medium.mutate((draft) => {
draft.hello = "world";
});
const newObject = await medium.asyncMutate(async (draft) => {
draft.hello = await getWorld();
});