vue-hooks-plus
Version:
Vue hooks library
24 lines (23 loc) • 612 B
JavaScript
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;
;