@lwmacct/251220-npm-pkg-monorepo-utils
v0.5.0
Published
Utility functions library
Downloads
17
Readme
@lwmacct/251220-npm-pkg-monorepo-utils
一个简单的工具函数库。
安装
npm install @lwmacct/251220-npm-pkg-monorepo-utils使用
import { greet, randomId, formatDate, sleep } from "@lwmacct/251220-npm-pkg-monorepo-utils";
// 问候
greet("World"); // => "Hello, World!"
// 生成随机 ID
randomId(); // => "a1b2c3d4"
randomId(12); // => "a1b2c3d4e5f6"
// 格式化日期
formatDate(); // => "2025-12-20"
formatDate(new Date("2024-01-01")); // => "2024-01-01"
// 异步等待
await sleep(1000); // 等待 1 秒API
| 函数 | 参数 | 返回值 | 说明 |
| ------------------- | ----------------- | --------------- | ------------------- |
| greet(name) | string | string | 返回问候语 |
| randomId(length?) | number (默认 8) | string | 生成随机 ID |
| formatDate(date?) | Date (默认当前) | string | 格式化为 YYYY-MM-DD |
| sleep(ms) | number | Promise<void> | 异步等待指定毫秒 |
License
MIT
