UNPKG

vue-hooks-plus

Version:
49 lines (48 loc) 1.03 kB
import { Ref } from 'vue'; type UseMapValue<K, T> = Iterable<readonly [K, T]>; type UseMapActions<K, T> = { /** * Add item * @param key K * @param value T * @returns void */ set: (key: K, value: T) => void; /** * Get item * @param key K * @param value T * @returns undefined */ get: (key: K) => T | undefined; /** * Remove key * @param key K * @returns void */ remove: (key: K) => void; /** * Add item * @param key K * @returns boolean */ has: (key: K) => boolean; /** * clear * @returns void */ clear: () => void; /** * Set a new Map * @param newMap UseMapValue<K, T> * @returns void */ setAll: (newMap: UseMapValue<K, T>) => void; /** * Reset to default * @returns void */ reset: () => void; }; declare function useMap<K, T>(initialValue?: UseMapValue<K, T>): [Readonly<Ref<Map<K, T>>>, UseMapActions<K, T>]; export default useMap;