env.ts
This file
Path
src/crap/env.ts
40 lines · 1.2 KiB · TypeScript
Last changed by
Moving files into foldersMichel Weststratebefore adoptionab49edc
History of this fileTake it
Moving files into foldersMichel Weststratebefore adoptionab49edc
lines 1–40why, one step back1// Should be no imports here!23// SOme things that should be evaluated before all else...4const hasSymbol = typeof Symbol !== "undefined"5export const hasMap = typeof Map !== "undefined"6export const hasSet = typeof Set !== "undefined"78/**9 * The sentinel value returned by producers to replace the draft with undefined.10 */11export const NOTHING: Nothing = hasSymbol12 ? Symbol("immer-nothing")13 : ({["immer-nothing"]: true} as any)1415/**16 * To let Immer treat your class instances as plain immutable objects17 * (albeit with a custom prototype), you must define either an instance property18 * or a static property on each of your custom classes.19 *20 * Otherwise, your class instance will never be drafted, which means it won't be21 * safe to mutate in a produce callback.22 */23export const DRAFTABLE: unique symbol = hasSymbol24 ? Symbol("immer-draftable")25 : ("__$immer_draftable" as any)2627export const DRAFT_STATE: unique symbol = hasSymbol28 ? Symbol("immer-state")29 : ("__$immer_state" as any)3031export const iteratorSymbol: typeof Symbol.iterator = hasSymbol32 ? Symbol.iterator33 : ("@@iterator" as any)3435/** Use a class type for `nothing` so its type is unique */36export class Nothing {37 // This lets us do `Exclude<T, Nothing>`38 // @ts-ignore39 private _!: unique symbol40}