Skip to content

Commit bc8116c

Browse files
committed
✨ new features
1 parent 348af4a commit bc8116c

21 files changed

+1387
-649
lines changed

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# @coderlzw/utils
2+
3+
`@coderlzw/utils` 是一个轻量级的 JavaScript 实用工具库,提供了一系列常用的辅助函数,旨在简化日常开发中的常见任务。
4+
5+
## 特性
6+
7+
- 🚀 高性能:经过优化的函数实现,确保最佳性能
8+
- 🧩 模块化:可以单独引入需要的函数,减少打包体积
9+
- 📦 全面兼容:支持在 Node.js 和浏览器环境中使用
10+
- 🔧 类型安全:使用 TypeScript 编写,提供完整的类型定义
11+
- 📚 文档完善:详细的 API 文档和使用示例
12+
13+
## 安装
14+
15+
```bash
16+
npm i @coderlzw/utils
17+
18+
# or yarn
19+
yarn add @coderlzw/utils
20+
21+
# or pnpm
22+
pnpm add @coderlzw/utils
23+
``
24+
25+
26+
## 使用
27+
28+
```ts
29+
import { Base64Utils } from '@coderlzw/utils';
30+
Base64Utils.encode("Hello,世界"); // "SGVsbG/vvIzkuJbnlYw="
31+
Base64Utils.decode("SGVsbG/vvIzkuJbnlYw="); // "Hello,世界"
32+
```

generateIndex.sh

+19-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
#!/bin/bash
22

3-
# 指定源目录和目标 index.ts 文件的路径
4-
SRC_DIR="./src"
5-
INDEX_PATH="$SRC_DIR/index.ts"
6-
7-
# 清空 index.ts 文件
8-
echo "" > "$INDEX_PATH"
9-
10-
# 获取所有 TypeScript 文件并生成 export 语句
11-
find "$SRC_DIR" -type f -name "*.ts" ! -name "index.ts" | while read -r file; do
12-
# 生成相对路径
13-
relative_path="${file#./src/}" # 去掉前缀 ./src/
14-
# 去掉文件扩展名
15-
file_name=$(basename "$file" .ts)
16-
# 写入 export 语句
17-
echo "export { default as $file_name } from \"./${relative_path%.ts}\";" >> "$INDEX_PATH"
18-
done
19-
20-
echo "Generated $INDEX_PATH"
3+
echo 👌
4+
## 指定源目录和目标 index.ts 文件的路径
5+
#SRC_DIR="./src"
6+
#INDEX_PATH="$SRC_DIR/index.ts"
7+
#
8+
## 清空 index.ts 文件
9+
#echo "" > "$INDEX_PATH"
10+
#
11+
## 获取所有 TypeScript 文件并生成 export 语句
12+
#find "$SRC_DIR" -type f -name "*.ts" ! -name "index.ts" | while read -r file; do
13+
# # 生成相对路径
14+
# relative_path="${file#./src/}" # 去掉前缀 ./src/
15+
# # 去掉文件扩展名
16+
# file_name=$(basename "$file" .ts)
17+
# # 写入 export 语句
18+
# echo "export { default as $file_name } from \"./${relative_path%.ts}\";" >> "$INDEX_PATH"
19+
#done
20+
#
21+
#echo "Generated $INDEX_PATH"

package.json

+24-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "js_utils",
2+
"name": "@coderlzw/utils",
33
"version": "1.0.0",
4-
"description": "",
4+
"description": "一个实用的 JavaScript 工具库,提供常用的函数和辅助方法",
55
"main": "./dist/cjs/index.cjs",
66
"module": "./dist/esm/index.mjs",
77
"types": "./dist/types/index.d.ts",
@@ -13,9 +13,6 @@
1313
"default": "./dist/cjs/index.cjs"
1414
}
1515
},
16-
"files": [
17-
"dist"
18-
],
1916
"scripts": {
2017
"build": "bash generateIndex.sh && rollup -c",
2118
"lint:fix": "eslint --fix",
@@ -24,12 +21,28 @@
2421
},
2522
"keywords": [
2623
"javascript",
27-
"utils"
24+
"utils",
25+
"helpers",
26+
"utility",
27+
"functions"
2828
],
2929
"author": "coderlzw",
3030
"license": "MIT",
31+
"repository": {
32+
"type": "git",
33+
"url": "https://github.com/coderlzw-cn/js-utils.git"
34+
},
35+
"bugs": {
36+
"url": "https://github.com/coderlzw-cn/js-utils/issues"
37+
},
38+
"homepage": "https://github.com/coderlzw-cn/js-utils#readme",
39+
"files": [
40+
"dist"
41+
],
3142
"devDependencies": {
3243
"@eslint/js": "^9.12.0",
44+
"@rollup/plugin-node-resolve": "^15.3.0",
45+
"@rollup/plugin-typescript": "^12.1.0",
3346
"@types/jest": "^29.5.12",
3447
"@types/node": "^22.5.0",
3548
"eslint": "^9.12.0",
@@ -39,15 +52,14 @@
3952
"rollup": "^4.24.0",
4053
"rollup-plugin-delete": "^2.1.0",
4154
"rollup-plugin-terser": "^7.0.2",
42-
"rollup-plugin-typescript2": "^0.36.0",
4355
"ts-jest": "^29.2.5",
4456
"ts-node": "^10.9.2",
45-
"tslib": "^2.7.0",
46-
"typescript": "^5.5.4",
47-
"typescript-eslint": "^8.8.0",
48-
"vite": "^5.4.8"
57+
"typescript": "^5.6.0",
58+
"typescript-eslint": "^8.8.0"
59+
},
60+
"dependencies": {
61+
"tslib": "^2.7.0"
4962
},
50-
"packageManager": "[email protected]+sha256.a61b67ff6cc97af864564f4442556c22a04f2e5a7714fbee76a1011361d9b726",
5163
"engines": {
5264
"node": ">=16.13.0"
5365
}

0 commit comments

Comments
 (0)