UNPKG

mobx-keystone

Version:

A MobX powered state management solution based on data trees with first class support for TypeScript, snapshots, patches and much more

17 lines (13 loc) 518 B
import type { ModelPropTransform } from "../modelShared/prop" const _stringToBigIntTransform: ModelPropTransform<string, bigint> = { transform({ originalValue, cachedTransformedValue }) { return cachedTransformedValue ?? BigInt(originalValue) }, untransform({ transformedValue, cacheTransformedValue }) { if (typeof transformedValue === "bigint") { cacheTransformedValue() } return transformedValue.toString() }, } export const stringToBigIntTransform = () => _stringToBigIntTransform