Skip to content

feat: Added storage utility functions #59

Merged
prgmr99 merged 4 commits intomainfrom
feature/utils-workspace-yeom
Oct 21, 2025
Merged

feat: Added storage utility functions #59
prgmr99 merged 4 commits intomainfrom
feature/utils-workspace-yeom

Conversation

@prgmr99
Copy link
Copy Markdown
Member

@prgmr99 prgmr99 commented Oct 21, 2025

Description

localStorage를 편리하게 사용할 수 있는 storage 유틸리티 함수를 추가합니다.

총 3개의 주요 메서드(set, get, remove)를 제공하며, 다음과 같은 특징을 가집니다:

주요 기능

  • 타입 안전성: TypeScript 제네릭을 활용한 완전한 타입 지원
  • SSR 환경 대응: 서버 사이드 렌더링 환경에서 안전하게 동작
  • 자동 직렬화: JSON.stringify/parse를 통한 객체/배열 자동 저장/조회
  • 에러 핸들링: 포괄적인 예외 처리 및 손상된 데이터 자동 정리

API

  • set<T>(key: string, value: T): void - localStorage에 데이터 저장 (객체/배열 지원)
  • get<T>(key: string): T | null - localStorage에서 타입 안전한 데이터 조회
  • remove(key: string): void - localStorage에서 특정 키 제거

사용 예시

// 객체 저장
storageUtil.set("user", { id: 1, name: "John" });

// 타입 안전한 조회
const user = storageUtil.get<{ id: number; name: string }>("user");

// 데이터 제거
storageUtil.remove("user");

@prgmr99 prgmr99 self-assigned this Oct 21, 2025
@prgmr99 prgmr99 added the enhancement New feature or request label Oct 21, 2025
@klmhyeonwoo
Copy link
Copy Markdown
Member

klmhyeonwoo commented Oct 21, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 78.97% 293 / 371
🔵 Statements 78.97% 293 / 371
🔵 Functions 96.55% 28 / 29
🔵 Branches 88.8% 111 / 125
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
package/commonUtil/storage/index.ts 65.21% 54.54% 100% 65.21% 15-19, 25-26, 36-37, 60-64, 69-70
Generated in workflow #91 for commit 57c49c8 by the Vitest Coverage Report Action

Comment thread README.md Outdated
const debouncedFn = commonUtil.debounce(() => console.log("Called!"), 300); // Debounced function

// Storage utilities
storageUtil.set("user", { id: 1, name: "John" }); // Stores object in localStorage
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

엇 storage.set 이런 식으로 사용하는게 아닌가요 혹시?!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 잘못 작성했습니다! 바로 수정할게요!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다요!

Copy link
Copy Markdown
Member

@klmhyeonwoo klmhyeonwoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

갓-승준

@prgmr99 prgmr99 merged commit dc831e1 into main Oct 21, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants