common.d.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132
  1. import { Objectish, AnyObject, AnyMap, AnySet, ImmerState } from "../internal";
  2. /** Returns true if the given value is an Immer draft */
  3. export declare function isDraft(value: any): boolean;
  4. /** Returns true if the given value can be drafted by Immer */
  5. export declare function isDraftable(value: any): boolean;
  6. export declare function isPlainObject(value: any): boolean;
  7. /** Get the underlying object that is represented by the given draft */
  8. export declare function original<T>(value: T): T | undefined;
  9. export declare const ownKeys: (target: AnyObject) => PropertyKey[];
  10. export declare const getOwnPropertyDescriptors: <T>(o: T) => { [P in keyof T]: TypedPropertyDescriptor<T[P]>; } & {
  11. [x: string]: PropertyDescriptor;
  12. };
  13. export declare function each<T extends Objectish>(obj: T, iter: (key: string | number, value: any, source: T) => void, enumerableOnly?: boolean): void;
  14. export declare function getArchtype(thing: any): 0 | 1 | 2 | 3;
  15. export declare function has(thing: any, prop: PropertyKey): boolean;
  16. export declare function get(thing: AnyMap | AnyObject, prop: PropertyKey): any;
  17. export declare function set(thing: any, propOrOldValue: PropertyKey, value: any): void;
  18. export declare function is(x: any, y: any): boolean;
  19. export declare function isMap(target: any): target is AnyMap;
  20. export declare function isSet(target: any): target is AnySet;
  21. export declare function latest(state: ImmerState): any;
  22. export declare function shallowCopy(base: any): any;
  23. /**
  24. * Freezes draftable objects. Returns the original object.
  25. * By default freezes shallowly, but if the second argument is `true` it will freeze recursively.
  26. *
  27. * @param obj
  28. * @param deep
  29. */
  30. export declare function freeze<T>(obj: T, deep?: boolean): T;
  31. export declare function isFrozen(obj: any): boolean;
  32. //# sourceMappingURL=common.d.ts.map