diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e2116cc --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 dori + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index ac088d5..7272af0 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,88 @@ -##### 이름하여 유틸 함수 모음집 +# @dori/utils -##### stringUtil +A comprehensive collection of TypeScript utility functions for modern web development. -###### 문자열 관련 유틸함수 +## Features -##### objectUtil +- 🛠️ **Comprehensive**: String, object, cookie, number, and validation utilities +- 📦 **Tree-shakable**: Import only what you need +- 🔒 **Type-safe**: Full TypeScript support with type definitions +- ⚡ **Lightweight**: Minimal dependencies and optimized for performance +- 🧪 **Well-tested**: Extensive test coverage with comprehensive test cases -###### 오브젝트 관련 유틸함수 +## Installation -##### cookieUtil +```bash +npm install @dori/utils +# or +pnpm add @dori/utils +# or +yarn add @dori/utils +``` -###### 쿠키 관련 유틸 함수 +## Usage -##### 그 외에는 더 추가될 예정.. +```typescript +import { + stringUtil, + objectUtil, + cookieUtil, + numberUtil, + validationUtil, +} from "@dori/utils"; + +// String utilities +const escaped = stringUtil.escapeHtml("
Hello
"); +const unescaped = stringUtil.unescapeHtml("<div>Hello</div>"); + +// Object utilities +const cleaned = objectUtil.clearNullProperties({ a: 1, b: null, c: 3 }); +const frozen = objectUtil.deepFreeze({ a: { b: 1 } }); + +// Number utilities +const total = numberUtil.sum(1, 2, 3, 4, 5); // 15 +const difference = numberUtil.subtract(10, 3); // 7 + +// Validation utilities +const isValid = validationUtil.checkEmail("user@example.com"); // true +const isHttpUrl = validationUtil.checkHttpUrl("https://example.com"); // true + +// Cookie utilities +cookieUtil.setCookie("theme", "dark"); +const theme = cookieUtil.getCookie("theme"); +``` + +## API Reference + +### StringUtil + +- `escapeHtml(str: string): string` - Escapes HTML special characters +- `unescapeHtml(str: string): string` - Unescapes HTML entities + +### ObjectUtil + +- `clearNullProperties(obj: object): object` - Removes null/undefined properties +- `deepFreeze(obj: object): object` - Deep freezes an object recursively + +### NumberUtil + +- `sum(...numbers: number[]): number` - Calculates sum of numbers +- `subtract(...numbers: number[]): number` - Subtracts two numbers + +### ValidationUtil + +- `checkEmail(email: string): boolean` - Validates email format +- `checkHttpUrl(url: string): boolean` - Validates HTTP/HTTPS URL format + +### CookieUtil + +- `setCookie(name: string, value: string, options?: object): void` - Sets a cookie +- `getCookie(name: string): string | null` - Gets a cookie value + +## Contributing + +Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository. + +## License + +MIT License - see LICENSE file for details.