Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/hooks/useStorageState/ko/useStorageState.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## 인터페이스

```ts
function useStorageState(
function useStorageState<T>(
key: string,
options: Object
): readonly [
Expand Down Expand Up @@ -45,13 +45,13 @@ function useStorageState(
},
{
name: 'options.serializer',
type: 'Function',
type: '(value: Serializable<T>) => string',
required: false,
description: '상태 값을 문자열로 직렬화하는 함수예요.',
},
{
name: 'options.deserializer',
type: 'Function',
type: '(value: string) => Serializable<T>',
required: false,
description: '상태 값을 문자열에서 역직렬화하는 함수예요.',
},
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useStorageState/useStorageState.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ function useStorageState(
},
{
name: 'options.serializer',
type: 'Function',
type: '(value: Serializable<T>) => string',
required: false,
description: 'A function to serialize the state value to a string.',
},
{
name: 'options.deserializer',
type: 'Function',
type: '(value: string) => Serializable<T>',
required: false,
description: 'A function to deserialize the state value from a string.',
},
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useStorageState/useStorageState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
deserializer: (value: string) => Serializable<T>;
};

type SerializableGuard<T extends readonly any[]> = T[0] extends any

Check warning on line 24 in src/hooks/useStorageState/useStorageState.ts

View workflow job for this annotation

GitHub Actions / quality (lint)

Unexpected any. Specify a different type

Check warning on line 24 in src/hooks/useStorageState/useStorageState.ts

View workflow job for this annotation

GitHub Actions / quality (lint)

Unexpected any. Specify a different type
? T
: T[0] extends never
? 'Received a non-serializable value'
Expand All @@ -33,7 +33,7 @@
listeners.forEach(listener => listener());
};

function isPlainObject(value: unknown): value is Record<PropertyKey, any> {

Check warning on line 36 in src/hooks/useStorageState/useStorageState.ts

View workflow job for this annotation

GitHub Actions / quality (lint)

Unexpected any. Specify a different type
if (typeof value !== 'object') {
return false;
}
Expand All @@ -49,7 +49,7 @@
return Object.prototype.toString.call(value) === '[object Object]';
}

const ensureSerializable = <T extends readonly any[]>(value: T): SerializableGuard<T> => {

Check warning on line 52 in src/hooks/useStorageState/useStorageState.ts

View workflow job for this annotation

GitHub Actions / quality (lint)

Unexpected any. Specify a different type
if (
value[0] != null &&
!['string', 'number', 'boolean'].includes(typeof value[0]) &&
Expand All @@ -70,8 +70,8 @@
* @param {Object} [options] - Configuration options for storage behavior.
* @param {Storage} [options.storage=localStorage] - The storage type (`localStorage` or `sessionStorage`). Defaults to `localStorage`.
* @param {T} [options.defaultValue] - The initial value if no existing value is found.
* @param {Function} [options.serializer] - A function to serialize the state value to a string.
* @param {Function} [options.deserializer] - A function to deserialize the state value from a string.
* @param {(value: Serializable<T>) => string} [options.serializer] - A function to serialize the state value to a string.
* @param {(value: string) => Serializable<T>} [options.deserializer] - A function to deserialize the state value from a string.
*
* @returns {readonly [state: Serializable<T> | undefined, setState: (value: SetStateAction<Serializable<T> | undefined>) => void, refreshState: () => void]} A tuple:
* - state `Serializable<T> | undefined` - The current state value retrieved from storage;
Expand Down
Loading