|
1 | | -##### 이름하여 유틸 함수 모음집 |
| 1 | +# @dori/utils |
2 | 2 |
|
3 | | -##### stringUtil |
| 3 | +A comprehensive collection of TypeScript utility functions for modern web development. |
4 | 4 |
|
5 | | -###### 문자열 관련 유틸함수 |
| 5 | +## Features |
6 | 6 |
|
7 | | -##### objectUtil |
| 7 | +- 🛠️ **Comprehensive**: String, object, cookie, number, and validation utilities |
| 8 | +- 📦 **Tree-shakable**: Import only what you need |
| 9 | +- 🔒 **Type-safe**: Full TypeScript support with type definitions |
| 10 | +- ⚡ **Lightweight**: Minimal dependencies and optimized for performance |
| 11 | +- 🧪 **Well-tested**: Extensive test coverage with comprehensive test cases |
8 | 12 |
|
9 | | -###### 오브젝트 관련 유틸함수 |
| 13 | +## Installation |
10 | 14 |
|
11 | | -##### cookieUtil |
| 15 | +```bash |
| 16 | +npm install @dori/utils |
| 17 | +# or |
| 18 | +pnpm add @dori/utils |
| 19 | +# or |
| 20 | +yarn add @dori/utils |
| 21 | +``` |
12 | 22 |
|
13 | | -###### 쿠키 관련 유틸 함수 |
| 23 | +## Usage |
14 | 24 |
|
15 | | -##### 그 외에는 더 추가될 예정.. |
| 25 | +```typescript |
| 26 | +import { |
| 27 | + stringUtil, |
| 28 | + objectUtil, |
| 29 | + cookieUtil, |
| 30 | + numberUtil, |
| 31 | + validationUtil, |
| 32 | +} from "@dori/utils"; |
| 33 | + |
| 34 | +// String utilities |
| 35 | +const escaped = stringUtil.escapeHtml("<div>Hello</div>"); |
| 36 | +const unescaped = stringUtil.unescapeHtml("<div>Hello</div>"); |
| 37 | + |
| 38 | +// Object utilities |
| 39 | +const cleaned = objectUtil.clearNullProperties({ a: 1, b: null, c: 3 }); |
| 40 | +const frozen = objectUtil.deepFreeze({ a: { b: 1 } }); |
| 41 | + |
| 42 | +// Number utilities |
| 43 | +const total = numberUtil.sum(1, 2, 3, 4, 5); // 15 |
| 44 | +const difference = numberUtil.subtract(10, 3); // 7 |
| 45 | + |
| 46 | +// Validation utilities |
| 47 | +const isValid = validationUtil.checkEmail("user@example.com"); // true |
| 48 | +const isHttpUrl = validationUtil.checkHttpUrl("https://example.com"); // true |
| 49 | + |
| 50 | +// Cookie utilities |
| 51 | +cookieUtil.setCookie("theme", "dark"); |
| 52 | +const theme = cookieUtil.getCookie("theme"); |
| 53 | +``` |
| 54 | + |
| 55 | +## API Reference |
| 56 | + |
| 57 | +### StringUtil |
| 58 | + |
| 59 | +- `escapeHtml(str: string): string` - Escapes HTML special characters |
| 60 | +- `unescapeHtml(str: string): string` - Unescapes HTML entities |
| 61 | + |
| 62 | +### ObjectUtil |
| 63 | + |
| 64 | +- `clearNullProperties(obj: object): object` - Removes null/undefined properties |
| 65 | +- `deepFreeze(obj: object): object` - Deep freezes an object recursively |
| 66 | + |
| 67 | +### NumberUtil |
| 68 | + |
| 69 | +- `sum(...numbers: number[]): number` - Calculates sum of numbers |
| 70 | +- `subtract(...numbers: number[]): number` - Subtracts two numbers |
| 71 | + |
| 72 | +### ValidationUtil |
| 73 | + |
| 74 | +- `checkEmail(email: string): boolean` - Validates email format |
| 75 | +- `checkHttpUrl(url: string): boolean` - Validates HTTP/HTTPS URL format |
| 76 | + |
| 77 | +### CookieUtil |
| 78 | + |
| 79 | +- `setCookie(name: string, value: string, options?: object): void` - Sets a cookie |
| 80 | +- `getCookie(name: string): string | null` - Gets a cookie value |
| 81 | + |
| 82 | +## Contributing |
| 83 | + |
| 84 | +Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository. |
| 85 | + |
| 86 | +## License |
| 87 | + |
| 88 | +MIT License - see LICENSE file for details. |
0 commit comments