@edgenets/utils 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +67 -4
- package/dist/array/unique.d.ts +2 -0
- package/dist/array/unique.d.ts.map +1 -0
- package/dist/array/unique.js +4 -0
- package/dist/array/unique.js.map +1 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -20
- package/dist/index.js.map +1 -1
- package/dist/string/capitalize.d.ts +2 -0
- package/dist/string/capitalize.d.ts.map +1 -0
- package/dist/string/capitalize.js +6 -0
- package/dist/string/capitalize.js.map +1 -0
- package/dist/string/trim.d.ts +2 -0
- package/dist/string/trim.d.ts.map +1 -0
- package/dist/string/trim.js +4 -0
- package/dist/string/trim.js.map +1 -0
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/logger.js +2 -2
- package/dist/types/logger.js.map +1 -1
- package/dist/types/order.js +12 -15
- package/dist/types/order.js.map +1 -1
- package/dist/types/product.js +1 -2
- package/dist/types/user.js +1 -2
- package/package.json +3 -2
- package/tsconfig.json +3 -0
package/README.md
CHANGED
@@ -1,13 +1,76 @@
|
|
1
|
-
|
1
|
+
# @edgenets/utils
|
2
2
|
|
3
|
-
|
3
|
+
Edgenets utilities package containing common types and utilities.
|
4
4
|
|
5
|
-
|
5
|
+
---
|
6
6
|
|
7
|
+
用于存放各种实用工具函数、类型定义和常用的工具方法,如字符串处理、数组操作、日期格式化等。
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
```bash
|
14
|
+
npm install @edgenets/utils
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
### Import utilities
|
20
|
+
|
21
|
+
```typescript
|
22
|
+
import { capitalize, trim, unique, User } from "@edgenets/utils";
|
23
|
+
|
24
|
+
// 使用工具函数
|
25
|
+
console.log(capitalize("hello")); // "Hello"
|
26
|
+
console.log(trim(" hello ")); // "hello"
|
27
|
+
console.log(unique([1, 2, 2, 3])); // [1, 2, 3]
|
28
|
+
|
29
|
+
// 使用 User 类型定义
|
30
|
+
const newUser: User.Profile = {
|
31
|
+
id: 1,
|
32
|
+
name: "John Doe",
|
33
|
+
email: "john.doe@example.com",
|
34
|
+
createdAt: new Date(),
|
35
|
+
updatedAt: new Date(),
|
36
|
+
};
|
7
37
|
```
|
38
|
+
|
39
|
+
### 构建和发布
|
40
|
+
|
41
|
+
1. **构建**:运行 `npm run build`,会生成 `dist` 文件夹,包含编译后的 JavaScript 和类型定义文件。
|
42
|
+
|
43
|
+
2. **发布**:发布包到 npm,可以使用以下命令:
|
44
|
+
|
45
|
+
```bash
|
46
|
+
npm publish --access public
|
47
|
+
```
|
48
|
+
|
49
|
+
##### 包含内容
|
50
|
+
|
51
|
+
```text
|
52
|
+
@edgenets/utils
|
53
|
+
├── src
|
54
|
+
│ ├── types // 类型定义(如 User、Order 等)
|
55
|
+
│ │ ├── logger.ts
|
56
|
+
│ │ ├── product.ts
|
57
|
+
│ │ ├── order.ts
|
58
|
+
│ │ └── user.ts
|
59
|
+
│ ├── string
|
60
|
+
│ │ ├── capitalize.ts
|
61
|
+
│ │ └── trim.ts
|
62
|
+
│ ├── array
|
63
|
+
│ │ └── unique.ts
|
64
|
+
│ └── index.ts
|
65
|
+
├── package.json
|
66
|
+
├── tsconfig.json
|
67
|
+
└── README.md
|
68
|
+
```
|
69
|
+
|
70
|
+
```text
|
8
71
|
• 字符串处理函数
|
9
72
|
• 数组处理函数
|
10
73
|
• 日期处理函数
|
11
74
|
• 通用工具函数(如 debounce、throttle)
|
12
|
-
•
|
75
|
+
•
|
13
76
|
```
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"unique.d.ts","sourceRoot":"","sources":["../../src/array/unique.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAEvC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"unique.js","sourceRoot":"","sources":["../../src/array/unique.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,MAAM,CAAI,GAAQ;IAChC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3B,CAAC"}
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
-
export * from "./types/user";
|
2
|
-
export * from "./types/product";
|
3
|
-
export * from "./types/logger";
|
4
|
-
export * from "./types/order";
|
1
|
+
export * from "./types/user.js";
|
2
|
+
export * from "./types/product.js";
|
3
|
+
export * from "./types/logger.js";
|
4
|
+
export * from "./types/order.js";
|
5
|
+
export * from "./string/capitalize.js";
|
6
|
+
export * from "./string/trim.js";
|
7
|
+
export * from "./array/unique.js";
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
@@ -1,21 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
-
};
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./types/user"), exports);
|
18
|
-
__exportStar(require("./types/product"), exports);
|
19
|
-
__exportStar(require("./types/logger"), exports);
|
20
|
-
__exportStar(require("./types/order"), exports);
|
1
|
+
// 导出类型定义
|
2
|
+
export * from "./types/user.js";
|
3
|
+
export * from "./types/product.js";
|
4
|
+
export * from "./types/logger.js";
|
5
|
+
export * from "./types/order.js";
|
6
|
+
// 导出字符串处理函数
|
7
|
+
export * from "./string/capitalize.js";
|
8
|
+
export * from "./string/trim.js";
|
9
|
+
// 导出数组处理函数
|
10
|
+
export * from "./array/unique.js";
|
21
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,YAAY;AACZ,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AAEjC,WAAW;AACX,cAAc,mBAAmB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"capitalize.d.ts","sourceRoot":"","sources":["../../src/string/capitalize.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG9C"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"capitalize.js","sourceRoot":"","sources":["../../src/string/capitalize.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"trim.d.ts","sourceRoot":"","sources":["../../src/string/trim.ts"],"names":[],"mappings":"AAAA,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"trim.js","sourceRoot":"","sources":["../../src/string/trim.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,IAAI,CAAC,GAAW;IAC9B,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;AACpB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/types/logger.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/types/logger.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAE9B"}
|
package/dist/types/logger.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
// src/interfaces/Logger.ts
|
2
|
+
export {};
|
3
3
|
//# sourceMappingURL=logger.js.map
|
package/dist/types/logger.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/types/logger.ts"],"names":[],"mappings":""}
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/types/logger.ts"],"names":[],"mappings":"AAAA,2BAA2B"}
|
package/dist/types/order.js
CHANGED
@@ -1,50 +1,47 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.ShippingStatus = exports.ShippingMethod = exports.RefundStatus = exports.PaymentStatus = exports.PaymentMethod = exports.OrderStatus = void 0;
|
4
1
|
// 订单状态枚举
|
5
|
-
var OrderStatus;
|
2
|
+
export var OrderStatus;
|
6
3
|
(function (OrderStatus) {
|
7
4
|
OrderStatus["Pending"] = "pending";
|
8
5
|
OrderStatus["Confirmed"] = "confirmed";
|
9
6
|
OrderStatus["Completed"] = "completed";
|
10
7
|
OrderStatus["Canceled"] = "canceled";
|
11
8
|
OrderStatus["Refunded"] = "refunded";
|
12
|
-
})(OrderStatus || (
|
9
|
+
})(OrderStatus || (OrderStatus = {}));
|
13
10
|
// 支付方式枚举
|
14
|
-
var PaymentMethod;
|
11
|
+
export var PaymentMethod;
|
15
12
|
(function (PaymentMethod) {
|
16
13
|
PaymentMethod["Online"] = "Online";
|
17
14
|
PaymentMethod["Credit"] = "Credit";
|
18
15
|
PaymentMethod["Points"] = "Points";
|
19
16
|
PaymentMethod["Crypto"] = "Crypto";
|
20
|
-
})(PaymentMethod || (
|
17
|
+
})(PaymentMethod || (PaymentMethod = {}));
|
21
18
|
// 支付状态枚举
|
22
|
-
var PaymentStatus;
|
19
|
+
export var PaymentStatus;
|
23
20
|
(function (PaymentStatus) {
|
24
21
|
PaymentStatus["Pending"] = "pending";
|
25
22
|
PaymentStatus["Paid"] = "paid";
|
26
23
|
PaymentStatus["Failed"] = "failed";
|
27
|
-
})(PaymentStatus || (
|
24
|
+
})(PaymentStatus || (PaymentStatus = {}));
|
28
25
|
// 退款状态枚举
|
29
|
-
var RefundStatus;
|
26
|
+
export var RefundStatus;
|
30
27
|
(function (RefundStatus) {
|
31
28
|
RefundStatus["Requested"] = "requested";
|
32
29
|
RefundStatus["Processing"] = "processing";
|
33
30
|
RefundStatus["Completed"] = "completed";
|
34
31
|
RefundStatus["Rejected"] = "rejected";
|
35
|
-
})(RefundStatus || (
|
32
|
+
})(RefundStatus || (RefundStatus = {}));
|
36
33
|
// 配送方式枚举
|
37
|
-
var ShippingMethod;
|
34
|
+
export var ShippingMethod;
|
38
35
|
(function (ShippingMethod) {
|
39
36
|
ShippingMethod["Standard"] = "standard";
|
40
37
|
ShippingMethod["Express"] = "express";
|
41
38
|
ShippingMethod["Pickup"] = "pickup";
|
42
|
-
})(ShippingMethod || (
|
39
|
+
})(ShippingMethod || (ShippingMethod = {}));
|
43
40
|
// 配送状态枚举
|
44
|
-
var ShippingStatus;
|
41
|
+
export var ShippingStatus;
|
45
42
|
(function (ShippingStatus) {
|
46
43
|
ShippingStatus["NotShipped"] = "not_shipped";
|
47
44
|
ShippingStatus["Shipped"] = "shipped";
|
48
45
|
ShippingStatus["Delivered"] = "delivered";
|
49
|
-
})(ShippingStatus || (
|
46
|
+
})(ShippingStatus || (ShippingStatus = {}));
|
50
47
|
//# sourceMappingURL=order.js.map
|
package/dist/types/order.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"order.js","sourceRoot":"","sources":["../../src/types/order.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"order.js","sourceRoot":"","sources":["../../src/types/order.ts"],"names":[],"mappings":"AAsBA,SAAS;AACT,MAAM,CAAN,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,oCAAqB,CAAA;IACrB,oCAAqB,CAAA;AACvB,CAAC,EANW,WAAW,KAAX,WAAW,QAMtB;AA+BD,SAAS;AACT,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;AACnB,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB;AAED,SAAS;AACT,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,8BAAa,CAAA;IACb,kCAAiB,CAAA;AACnB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAED,SAAS;AACT,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,uCAAuB,CAAA;IACvB,yCAAyB,CAAA;IACzB,uCAAuB,CAAA;IACvB,qCAAqB,CAAA;AACvB,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAoBD,SAAS;AACT,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;AACnB,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB;AAED,SAAS;AACT,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,4CAA0B,CAAA;IAC1B,qCAAmB,CAAA;IACnB,yCAAuB,CAAA;AACzB,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB"}
|
package/dist/types/product.js
CHANGED
package/dist/types/user.js
CHANGED
package/package.json
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "@edgenets/utils",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.2",
|
4
4
|
"description": "Edgenets utilities package containing common types and utilities.",
|
5
5
|
"type": "module",
|
6
6
|
"main": "dist/index.js",
|
7
7
|
"types": "dist/index.d.ts",
|
8
8
|
"author": "Edgenets",
|
9
|
+
"license": "MIT",
|
9
10
|
"scripts": {
|
10
11
|
"build": "eslint --fix && tsc -p tsconfig.json",
|
11
|
-
"test": "tsx
|
12
|
+
"test": "tsx node_modules/tap/dist/esm/run.mjs 'test/**/*.spec.ts' || true"
|
12
13
|
}
|
13
14
|
}
|