UNPKG

vue-hooks-plus

Version:
24 lines (23 loc) 612 B
"use strict"; const vue = require("vue"); function useSet(initialValue) { const getInitValue = () => { return initialValue === void 0 ? /* @__PURE__ */ new Set() : new Set(initialValue); }; const state = vue.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 [vue.readonly(state), vue.markRaw(actions)]; } module.exports = useSet;