一个现代化的 TypeScript 工具库,提供常用的工具函数集合。
npm install @cgboiler/corebash
npm install @cgboiler/core
或者使用 yarn
yarn add @cgboiler/core
或者使用 pnpm
pnpm add @cgboiler/core
`
使用
`typescript
import { capitalize, unique, deepClone } from '@cgboiler/core';
// 字符串操作
console.log(capitalize('hello')); // 'Hello'
// 数组操作
console.log(unique([1, 1, 2, 2, 3])); // [1, 2, 3]
// 对象操作
const obj = { a: 1, b: { c: 2 } };
const cloned = deepClone(obj);
`
API 文档
$3
- capitalize(str: string): string - 将字符串的首字母转换为大写
- camelToKebab(str: string): string - 将驼峰命名转换为短横线命名
- kebabToCamel(str: string): string - 将短横线命名转换为驼峰命名
$3
- unique - 数组去重
- groupBy - 数组分组
- flatten - 数组扁平化
$3
- deepClone - 深拷贝对象
- flattenObject(obj: Record - 对象扁平化
- pick - 选择对象中的指定属性
开发
`bash
安装依赖
pnpm install
开发模式
pnpm dev
构建
pnpm build
运行测试
pnpm test
代码格式化
pnpm format
代码检查
pnpm lint
``