Skip to content

Commit

Permalink
type: no check
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonYong committed Jul 7, 2024
1 parent bd880c3 commit e4ed657
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/hooks/src/useSet/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { ref, Ref, markRaw, readonly, UnwrapRef } from 'vue'
// @ts-nocheck

import { ref, Ref, markRaw, readonly } from 'vue'

interface UseSetActions<T> {
add: (value: T) => void
Expand All @@ -8,38 +10,36 @@ interface UseSetActions<T> {
reset: () => void
}

function useSet<T = any>(
initialValue?: UnwrapRef<T>[],
): [Readonly<Ref<Set<UnwrapRef<T>>>>, UseSetActions<UnwrapRef<T>>]
function useSet<T = any>(initialValue?: T[]): [Readonly<Ref<Set<T>>>, UseSetActions<T>]

function useSet<T = any>(initialValue?: UnwrapRef<T>[]) {
function useSet<T = any>(initialValue?: T[]) {
const getInitValue = () => {
return initialValue === undefined ? new Set<UnwrapRef<T>>() : new Set(initialValue)
return initialValue === undefined ? new Set<T>() : new Set(initialValue)
}
const state = ref(getInitValue())

const actions: UseSetActions<UnwrapRef<T>> = {
const actions: UseSetActions<T> = {
/**
* Add item
* @param value T
*/
add: value => {
add: (value: T) => {
state.value.add(value)
},

/**
* Remove item
* @param value T
*/
remove: value => {
remove: (value: T) => {
state.value.delete(value)
},

/**
* Set has
* @param value T
*/
has: value => state.value.has(value),
has: (value: T) => state.value.has(value),

/**
* Clear Set
Expand Down

0 comments on commit e4ed657

Please sign in to comment.