@edgenets/utils 0.0.1 → 0.0.2

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 CHANGED
@@ -1,13 +1,76 @@
1
- ## @edgenets/utils
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
- 类型定义(如 User、Order 等)
75
+
13
76
  ```
@@ -0,0 +1,2 @@
1
+ export declare function unique<T>(arr: T[]): T[];
2
+ //# sourceMappingURL=unique.d.ts.map
@@ -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,4 @@
1
+ export function unique(arr) {
2
+ return [...new Set(arr)];
3
+ }
4
+ //# sourceMappingURL=unique.js.map
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
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
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
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":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,kDAAgC;AAChC,iDAA+B;AAC/B,gDAA8B"}
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,2 @@
1
+ export declare function capitalize(str: string): string;
2
+ //# sourceMappingURL=capitalize.d.ts.map
@@ -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,6 @@
1
+ export function capitalize(str) {
2
+ if (!str)
3
+ return "";
4
+ return str.charAt(0).toUpperCase() + str.slice(1);
5
+ }
6
+ //# sourceMappingURL=capitalize.js.map
@@ -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,2 @@
1
+ export declare function trim(str: string): string;
2
+ //# sourceMappingURL=trim.d.ts.map
@@ -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,4 @@
1
+ export function trim(str) {
2
+ return str.trim();
3
+ }
4
+ //# sourceMappingURL=trim.js.map
@@ -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":"AACA,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAE9B"}
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"}
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ // src/interfaces/Logger.ts
2
+ export {};
3
3
  //# sourceMappingURL=logger.js.map
@@ -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"}
@@ -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 || (exports.OrderStatus = 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 || (exports.PaymentMethod = 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 || (exports.PaymentStatus = 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 || (exports.RefundStatus = 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 || (exports.ShippingMethod = 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 || (exports.ShippingStatus = ShippingStatus = {}));
46
+ })(ShippingStatus || (ShippingStatus = {}));
50
47
  //# sourceMappingURL=order.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"order.js","sourceRoot":"","sources":["../../src/types/order.ts"],"names":[],"mappings":";;;AAsBA,SAAS;AACT,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,oCAAqB,CAAA;IACrB,oCAAqB,CAAA;AACvB,CAAC,EANW,WAAW,2BAAX,WAAW,QAMtB;AA+BD,SAAS;AACT,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;AACnB,CAAC,EALW,aAAa,6BAAb,aAAa,QAKxB;AAED,SAAS;AACT,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,8BAAa,CAAA;IACb,kCAAiB,CAAA;AACnB,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB;AAED,SAAS;AACT,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,uCAAuB,CAAA;IACvB,yCAAyB,CAAA;IACzB,uCAAuB,CAAA;IACvB,qCAAqB,CAAA;AACvB,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAoBD,SAAS;AACT,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;AACnB,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AAED,SAAS;AACT,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,4CAA0B,CAAA;IAC1B,qCAAmB,CAAA;IACnB,yCAAuB,CAAA;AACzB,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB"}
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"}
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=product.js.map
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=user.js.map
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@edgenets/utils",
3
- "version": "0.0.1",
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 ../../node_modules/tap/dist/esm/run.mjs 'test/**/*.spec.ts' || true"
12
+ "test": "tsx node_modules/tap/dist/esm/run.mjs 'test/**/*.spec.ts' || true"
12
13
  }
13
14
  }
package/tsconfig.json CHANGED
@@ -1,5 +1,8 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "target": "ES6",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "nodenext",
3
6
  "outDir": "./dist",
4
7
  "rootDir": "./src",
5
8
  "sourceMap": true,