tg-map-vue3
Version:
封装 百度地图, Google地图, Here地图(未完成) 的Vue3组件库
35 lines (34 loc) • 1.24 kB
TypeScript
/** 键值对 */
export declare class KeyValue<K, V> {
private keyToValue;
private valueToKey;
/**
* `keys`和`values`数组中可以有相同的值, 若存在相同值, 则index越小的优先级越高
*/
constructor(keys: K[], values: V[]);
toKey(value: V): K;
toValue(key: K): V;
}
export type KeySelector<T, K> = (this: T) => K;
/** 用key快速查找元素的数组 */
export declare class FastFindValues<T> {
values: readonly T[];
private maxSize4Debug;
private map;
constructor(values: readonly T[], maxSize4Debug?: number);
/** 获取保存key-value映射的Map */
getValueMap<K>(keySelector: KeySelector<T, K>): Map<K, T>;
/**
* 直接用key获取value
* @param keySelector 从T中读取key的方法, 会用它当key, 缓存结果, 故多次调用需要使用相同的keySelector对象, 不要每次创建新的, 推荐直接使用T.prototype.getXxx作为keySelector
*/
getOrNull<K>(keySelector: KeySelector<T, K>, key: K): T | undefined;
get<K>(keySelector: KeySelector<T, K>, key: K): T;
}
/** 缓存的值 */
export declare class CachedValue<T> {
private creator;
private value;
constructor(creator: () => T);
get(): T;
}