diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1db9248..2b2b1ec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,7 +1,7 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: - autoInstallPeers: true + autoInstallPeers: false excludeLinksFromLockfile: false dependencies: diff --git a/useCloned/jiwon.ts b/useCloned/jiwon.ts new file mode 100644 index 0000000..3bd9b51 --- /dev/null +++ b/useCloned/jiwon.ts @@ -0,0 +1,24 @@ +import { ref, toValue, watch } from "vue" + +type Options = { + immediate?: boolean + deep?: boolean + manual?: boolean + clone?: (value: any) => any +} + +export const useCloned = (source:object, options?:Options) => { + const cloned = ref(toValue(source)) + const originSource = JSON.parse(JSON.stringify(toValue(source))) + + const sync = () => { + cloned.value = toValue(source) + } + + if (options?.manual) { + cloned.value = originSource + } + + + return {cloned, sync} +} \ No newline at end of file diff --git a/useMemoize/index.test.ts b/useMemoize/index.test.ts index 03d3e93..f64d047 100644 --- a/useMemoize/index.test.ts +++ b/useMemoize/index.test.ts @@ -1,8 +1,8 @@ import type { Mock } from 'vitest' import { beforeEach, describe, expect, it, vi } from 'vitest' import { computed } from 'vue-demi' -import type { UseMemoizeCache } from '.' -import { useMemoize } from '.' +import type { UseMemoizeCache } from './jiwon' +import { useMemoize } from './jiwon' describe('useMemoize', () => { const resolver = vi.fn() @@ -12,10 +12,6 @@ describe('useMemoize', () => { resolver.mockImplementation((arg1: number) => `result-${arg1}`) }) - it('should be defined', () => { - expect(useMemoize).toBeDefined() - }) - describe('get', () => { it('should load and cache data on get', () => { const memo = useMemoize(resolver) @@ -98,6 +94,7 @@ describe('useMemoize', () => { expect(memo(1)).toBe('result-1') expect(resolver).not.toHaveBeenCalled() + expect(value1.value).toBe('result-1') expect(memo.load(1)).toBe('new-result-1') expect(resolver).toHaveBeenCalledTimes(1) diff --git a/useUrlSearchParams/index.ts b/useUrlSearchParams/index.ts new file mode 100644 index 0000000..a40066e --- /dev/null +++ b/useUrlSearchParams/index.ts @@ -0,0 +1,3 @@ +export const useUrlSearchParams = (search: string) => { + +} \ No newline at end of file