@fsyyft/npmjs-add 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +153 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# @fsyyft/npmjs-add
|
|
2
|
+
|
|
3
|
+
> 一个简单的加法工具库
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@fsyyft/npmjs-add)
|
|
6
|
+
[](https://www.npmjs.com/package/@fsyyft/npmjs-add)
|
|
7
|
+
|
|
8
|
+
## 特性
|
|
9
|
+
|
|
10
|
+
- 📦 零依赖
|
|
11
|
+
- 🎯 支持 TypeScript
|
|
12
|
+
- 🔄 兼容 ESM 和 CommonJS
|
|
13
|
+
- 🚀 包含 CLI 工具
|
|
14
|
+
- ✅ 完整的测试覆盖
|
|
15
|
+
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @fsyyft/npmjs-add
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 使用方法
|
|
23
|
+
|
|
24
|
+
### 作为库使用
|
|
25
|
+
|
|
26
|
+
**CommonJS:**
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
const { add } = require('@fsyyft/npmjs-add');
|
|
30
|
+
|
|
31
|
+
console.log(add(1, 2)); // 3
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**ESM:**
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
import { add } from '@fsyyft/npmjs-add';
|
|
38
|
+
|
|
39
|
+
console.log(add(10, 20)); // 30
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**TypeScript:**
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { add } from '@fsyyft/npmjs-add';
|
|
46
|
+
|
|
47
|
+
const result: number = add(100, 200);
|
|
48
|
+
console.log(result); // 300
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 作为 CLI 工具
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# 全局安装
|
|
55
|
+
npm install -g @fsyyft/npmjs-add
|
|
56
|
+
|
|
57
|
+
# 或使用 npx(无需安装)
|
|
58
|
+
npx npmjs-add 1 2
|
|
59
|
+
# 输出: 3
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## API
|
|
63
|
+
|
|
64
|
+
### `add(a, b)`
|
|
65
|
+
|
|
66
|
+
计算两个数的和。
|
|
67
|
+
|
|
68
|
+
**参数:**
|
|
69
|
+
|
|
70
|
+
| 名称 | 类型 | 描述 |
|
|
71
|
+
|------|------|-------------|
|
|
72
|
+
| `a` | `number` | 第一个数 |
|
|
73
|
+
| `b` | `number` | 第二个数 |
|
|
74
|
+
|
|
75
|
+
**返回值:** `number` - a 和 b 的和
|
|
76
|
+
|
|
77
|
+
**示例:**
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
add(1, 2); // 3
|
|
81
|
+
add(-1, 5); // 4
|
|
82
|
+
add(0.1, 0.2); // 0.30000000000000004
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## CLI 使用
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npmjs-add <数字1> <数字2>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**示例:**
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npmjs-add 1 2 # 3
|
|
95
|
+
npmjs-add 100 200 # 300
|
|
96
|
+
npmjs-add -5 3 # -2
|
|
97
|
+
npmjs-add 1.5 2.5 # 4
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 文档
|
|
101
|
+
|
|
102
|
+
更多文档请查看 [docs](./docs) 目录:
|
|
103
|
+
|
|
104
|
+
- [项目结构](./docs/project-structure.md) - 项目结构和文件说明
|
|
105
|
+
- [本地开发指南](./docs/local-development-guide.md) - 如何本地开发和测试
|
|
106
|
+
- [发布指南](./docs/publishing-guide.md) - 如何发布到 npm
|
|
107
|
+
|
|
108
|
+
## 开发
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# 克隆仓库
|
|
112
|
+
git clone https://github.com/fsyyft-ts/npmjs-add.git
|
|
113
|
+
|
|
114
|
+
# 安装依赖
|
|
115
|
+
npm install
|
|
116
|
+
|
|
117
|
+
# 开发模式运行
|
|
118
|
+
npm run dev
|
|
119
|
+
|
|
120
|
+
# 运行测试
|
|
121
|
+
npm test
|
|
122
|
+
|
|
123
|
+
# 运行代码检查
|
|
124
|
+
npm run lint
|
|
125
|
+
|
|
126
|
+
# 构建项目
|
|
127
|
+
npm run build
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## 发布
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# 测试发布脚本(不实际发布)
|
|
134
|
+
npm run test:publish
|
|
135
|
+
|
|
136
|
+
# 发布到 npm
|
|
137
|
+
npm run publish:npm
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
详细说明请查看 [发布指南](./docs/publishing-guide.md)。
|
|
141
|
+
|
|
142
|
+
## 许可证
|
|
143
|
+
|
|
144
|
+
ISC
|
|
145
|
+
|
|
146
|
+
## 作者
|
|
147
|
+
|
|
148
|
+
fsyyft
|
|
149
|
+
|
|
150
|
+
## 链接
|
|
151
|
+
|
|
152
|
+
- [npm 包](https://www.npmjs.com/package/@fsyyft/npmjs-add)
|
|
153
|
+
- [GitHub 仓库](https://github.com/fsyyft-ts/npmjs-add)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fsyyft/npmjs-add",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "A simple addition utility library",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"lint:fix": "eslint src --fix",
|
|
21
21
|
"test": "vitest",
|
|
22
22
|
"test:run": "vitest run",
|
|
23
|
+
"test:publish": "bash scripts/test-publish.sh",
|
|
23
24
|
"publish:npm": "bash scripts/publish.sh"
|
|
24
25
|
},
|
|
25
26
|
"repository": {
|