UNPKG

vue-hooks-plus

Version:
25 lines (24 loc) 611 B
import { ref, readonly, markRaw } from "vue"; function useSet(initialValue) { const getInitValue = () => { return initialValue === void 0 ? /* @__PURE__ */ new Set() : new Set(initialValue); }; const state = ref(getInitValue()); const actions = { add: (value) => { state.value.add(value); }, remove: (value) => { state.value.delete(value); }, has: (value) => state.value.has(value), clear: () => state.value.clear(), reset: () => { state.value = getInitValue(); } }; return [readonly(state), markRaw(actions)]; } export { useSet as default };