mobx-keystone-mindreframer
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) • 960 B
TypeScript
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<T>(array: Array<[string, T]>): ObservableMap<string, T> & {
dataObject: Array<[string, T]>;
};
/**
* 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: Map<string, T>): 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<T>(map: Map<string, T>): Array<[string, T]>;