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

30 lines (29 loc) 946 B
import { ObservableMap } from 'mobx'; /** * Wraps an observable object or a tuple array to offer a map like interface. * * @param array Array. */ export declare function asMap<K, V>(array: Array<[K, V]>): ObservableMap<K, V> & { dataObject: Array<[K, V]>; }; /** * Wraps an observable object or a tuple array to offer a map like interface. * * @param object Object. */ export declare function asMap<T>(object: Record<string, T>): ObservableMap<string, T> & { dataObject: Record<string, T>; }; /** * Converts a map to an object. If the map is a collection wrapper it will return the backed object. * * @param map */ export declare function mapToObject<T>(map: Pick<Map<string, T>, "forEach">): Record<string, T>; /** * Converts a map to an array. If the map is a collection wrapper it will return the backed array. * * @param map */ export declare function mapToArray<K, V>(map: Pick<Map<K, V>, "forEach">): Array<[K, V]>;