jz-toolkit 1.0.4 → 1.0.6

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,6 +1,6 @@
1
- # jzlib
1
+ # jz-toolkit
2
2
 
3
- 🚀 一个轻量级、功能丰富的 JavaScript/TypeScript 工具库,类似 Lodash,但更小更快。
3
+ 🚀 一个轻量级、功能丰富的 JavaScript/TypeScript 工具库。
4
4
 
5
5
  ## 特点
6
6
 
@@ -14,55 +14,46 @@
14
14
 
15
15
  📚 **良好文档** - 每个函数都有详细的文档和示例
16
16
 
17
-
18
- ## 文档查阅
19
- ## JZ Toolkit 文档
20
-
21
- 基于 VitePress 构建的工具库文档站点。
22
-
23
-
24
-
25
- 大家可以访问 http://172.81.245.148:8098/api/utils.html 查看文档。
26
-
27
-
28
-
29
-
30
17
  ## 安装
31
18
 
32
19
  ```bash
33
- npm install jzlib
20
+ npm i jz-toolkit
34
21
  ```
35
22
 
23
+ ## 官方文档地址
24
+
25
+ http://172.81.245.148:8098/api/utils.html
26
+
36
27
  ## 快速开始
37
28
 
38
29
  ### 完整导入
39
30
 
40
31
  ```typescript
41
- import * as _ from 'jzlib';
32
+ import * as _ from "jz-toolkit";
42
33
 
43
- _.chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
44
- _.capitalize('hello'); // 'Hello'
34
+ _.chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
35
+ _.capitalize("hello"); // 'Hello'
45
36
  ```
46
37
 
47
38
  ### 按需导入
48
39
 
49
40
  ```typescript
50
- import { chunk, capitalize } from 'jzlib';
41
+ import { chunk, capitalize } from "jz-toolkit";
51
42
 
52
- chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
53
- capitalize('hello'); // 'Hello'
43
+ chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
44
+ capitalize("hello"); // 'Hello'
54
45
  ```
55
46
 
56
47
  ### 模块导入
57
48
 
58
49
  ```typescript
59
- import * as array from 'jzlib/array';
60
- import * as object from 'jzlib/object';
61
- import * as string from 'jzlib/string';
50
+ import * as array from "jz-toolkit/array";
51
+ import * as object from "jz-toolkit/object";
52
+ import * as string from "jz-toolkit/string";
62
53
 
63
54
  array.chunk([1, 2, 3, 4], 2);
64
- object.pick({ a: 1, b: 2 }, ['a']);
65
- string.capitalize('world');
55
+ object.pick({ a: 1, b: 2 }, ["a"]);
56
+ string.capitalize("world");
66
57
  ```
67
58
 
68
59
  ## 📚 API 文档
@@ -70,6 +61,7 @@ string.capitalize('world');
70
61
  ### 数组 (Array)
71
62
 
72
63
  #### `chunk(array, size)`
64
+
73
65
  将数组分成指定大小的块。
74
66
 
75
67
  ```typescript
@@ -78,52 +70,58 @@ chunk([1, 2, 3, 4, 5], 2);
78
70
  ```
79
71
 
80
72
  #### `compact(array)`
73
+
81
74
  移除数组中的虚值。
82
75
 
83
76
  ```typescript
84
- compact([0, 1, false, 2, '', 3, undefined, 4, null, NaN]);
77
+ compact([0, 1, false, 2, "", 3, undefined, 4, null, NaN]);
85
78
  // => [1, 2, 3, 4]
86
79
  ```
87
80
 
88
81
  ### 对象 (Object)
89
82
 
90
83
  #### `pick(obj, keys)`
84
+
91
85
  从对象中选择指定的属性。
92
86
 
93
87
  ```typescript
94
- pick({ a: 1, b: 2, c: 3 }, ['a', 'c']);
88
+ pick({ a: 1, b: 2, c: 3 }, ["a", "c"]);
95
89
  // => { a: 1, c: 3 }
96
90
  ```
97
91
 
98
92
  #### `omit(obj, keys)`
93
+
99
94
  从对象中排除指定的属性。
100
95
 
101
96
  ```typescript
102
- omit({ a: 1, b: 2, c: 3 }, ['b']);
97
+ omit({ a: 1, b: 2, c: 3 }, ["b"]);
103
98
  // => { a: 1, c: 3 }
104
99
  ```
105
100
 
106
101
  ### 字符串 (String)
107
102
 
108
103
  #### `capitalize(str)`
104
+
109
105
  将字符串首字母转为大写。
110
106
 
111
107
  ```typescript
112
- capitalize('hello');
108
+ capitalize("hello");
113
109
  // => 'Hello'
114
110
  ```
115
111
 
116
112
  #### `camelCase(str)`
113
+
117
114
  将字符串转换为驼峰式命名法。
118
115
 
119
116
  ```typescript
120
- camelCase('hello-world');
117
+ camelCase("hello-world");
121
118
  // => 'helloWorld'
122
119
  ```
123
120
 
124
121
  ### 工具函数 (Utility)
125
122
 
126
123
  #### 类型检查
124
+
127
125
  - `isString(value)` - 检查是否为字符串
128
126
  - `isNumber(value)` - 检查是否为数字
129
127
  - `isBoolean(value)` - 检查是否为布尔值
@@ -139,49 +137,61 @@ camelCase('hello-world');
139
137
  - `isNullOrUndefined(value)` - 检查是否为 null 或 undefined
140
138
 
141
139
  #### `isEmpty(value)`
140
+
142
141
  检查值是否为空。
143
142
 
144
143
  ```typescript
145
- isEmpty([]); // => true
146
- isEmpty({}); // => true
147
- isEmpty(''); // => true
148
- isEmpty(null); // => true
149
- isEmpty('hello'); // => false
144
+ isEmpty([]); // => true
145
+ isEmpty({}); // => true
146
+ isEmpty(""); // => true
147
+ isEmpty(null); // => true
148
+ isEmpty("hello"); // => false
150
149
  ```
151
150
 
151
+ ### mapToArray
152
+
153
+ mapToArray(new Map<string, number>([["a", 1], ["b", 2], ["c", 3]])) // => [1, 2, 3]
154
+
152
155
  ## 开发
153
156
 
154
157
  ### 安装依赖
158
+
155
159
  ```bash
156
160
  npm install
157
161
  ```
158
162
 
159
163
  ### 构建
164
+
160
165
  ```bash
161
166
  npm run build
162
167
  ```
163
168
 
164
169
  ### 开发模式(监视文件变化)
170
+
165
171
  ```bash
166
172
  npm run dev
167
173
  ```
168
174
 
169
175
  ### 运行测试
176
+
170
177
  ```bash
171
178
  npm test
172
179
  ```
173
180
 
174
181
  ### 查看测试覆盖率
182
+
175
183
  ```bash
176
184
  npm run test:coverage
177
185
  ```
178
186
 
179
187
  ### 代码格式化
188
+
180
189
  ```bash
181
190
  npm run format
182
191
  ```
183
192
 
184
193
  ### Linting
194
+
185
195
  ```bash
186
196
  npm run lint
187
197
  ```
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.chunk = chunk;
3
+ exports.chunk = void 0;
4
4
  /**
5
5
  * 将数组分成指定大小的块
6
6
  * @param array 输入数组
@@ -21,3 +21,4 @@ function chunk(array, size) {
21
21
  }
22
22
  return result;
23
23
  }
24
+ exports.chunk = chunk;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compact = compact;
3
+ exports.compact = void 0;
4
4
  /**
5
5
  * 移除数组中的虚值(false、null、0、""、undefined 和 NaN)
6
6
  * @param array 输入数组
@@ -13,3 +13,4 @@ exports.compact = compact;
13
13
  function compact(array) {
14
14
  return array.filter((item) => Boolean(item));
15
15
  }
16
+ exports.compact = compact;
@@ -1,14 +1,13 @@
1
1
  /**
2
- * jzlib - 轻量级工具库
3
- * 类似 Lodash 的 JavaScript/TypeScript 工具函数集合
2
+ * jzlib - 轻量级工具库 JavaScript/TypeScript 工具函数集合
4
3
  */
5
- export * from './types';
6
- export * as array from './array';
7
- export * as object from './object';
8
- export * as string from './string';
9
- export * as utility from './utility';
10
- export { chunk, compact, } from './array';
11
- export { pick, omit, } from './object';
12
- export { capitalize, camelCase, } from './string';
13
- export { isString, isNumber, isBoolean, isNull, isUndefined, isNullOrUndefined, isArray, isObject, isFunction, isDate, isRegExp, isMap, isSet, isEmpty, } from './utility';
4
+ export * from "./types";
5
+ export * as array from "./array";
6
+ export * as object from "./object";
7
+ export * as string from "./string";
8
+ export * as utility from "./utility";
9
+ export { chunk, compact, } from "./array";
10
+ export { pick, omit, } from "./object";
11
+ export { capitalize, camelCase, } from "./string";
12
+ export { isString, isNumber, isBoolean, isNull, isUndefined, isNullOrUndefined, isArray, isObject, isFunction, isDate, isRegExp, isMap, isSet, isEmpty, } from "./utility";
14
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,SAAS,CAAC;AAGxB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAGrC,OAAO,EAEL,KAAK,EACL,OAAO,GACR,MAAM,SAAS,CAAC;AAEjB,OAAO,EAEL,IAAI,EACJ,IAAI,GACL,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,UAAU,EACV,SAAS,GACV,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,EACN,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,QAAQ,EACR,UAAU,EACV,MAAM,EACN,QAAQ,EACR,KAAK,EACL,KAAK,EACL,OAAO,GACR,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,SAAS,CAAC;AAGxB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAGrC,OAAO,EAEL,KAAK,EACL,OAAO,GACR,MAAM,SAAS,CAAC;AAEjB,OAAO,EAEL,IAAI,EACJ,IAAI,GACL,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,UAAU,EACV,SAAS,GACV,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,EACN,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,QAAQ,EACR,UAAU,EACV,MAAM,EACN,QAAQ,EACR,KAAK,EACL,KAAK,EACL,OAAO,GACR,MAAM,WAAW,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,24 +1,23 @@
1
1
  /**
2
- * jzlib - 轻量级工具库
3
- * 类似 Lodash 的 JavaScript/TypeScript 工具函数集合
2
+ * jzlib - 轻量级工具库 JavaScript/TypeScript 工具函数集合
4
3
  */
5
4
  // 类型导出
6
- export * from './types';
5
+ export * from "./types";
7
6
  // 功能模块导出
8
- export * as array from './array';
9
- export * as object from './object';
10
- export * as string from './string';
11
- export * as utility from './utility';
7
+ export * as array from "./array";
8
+ export * as object from "./object";
9
+ export * as string from "./string";
10
+ export * as utility from "./utility";
12
11
  // 直接导出常用函数
13
12
  export {
14
13
  // 数组
15
- chunk, compact, } from './array';
14
+ chunk, compact, } from "./array";
16
15
  export {
17
16
  // 对象
18
- pick, omit, } from './object';
17
+ pick, omit, } from "./object";
19
18
  export {
20
19
  // 字符串
21
- capitalize, camelCase, } from './string';
20
+ capitalize, camelCase, } from "./string";
22
21
  export {
23
22
  // 工具类
24
- isString, isNumber, isBoolean, isNull, isUndefined, isNullOrUndefined, isArray, isObject, isFunction, isDate, isRegExp, isMap, isSet, isEmpty, } from './utility';
23
+ isString, isNumber, isBoolean, isNull, isUndefined, isNullOrUndefined, isArray, isObject, isFunction, isDate, isRegExp, isMap, isSet, isEmpty, } from "./utility";
@@ -0,0 +1,2 @@
1
+ export * from "./mapToArray";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mapToArray/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./mapToArray";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 将 Map 转换为数组
3
+ * @param map 输入 Map
4
+ * @returns 转换后的数组
5
+ *
6
+ * @example
7
+ * mapToArray(new Map<string, number>([["a", 1], ["b", 2], ["c", 3]])) // => [1, 2, 3]
8
+ */
9
+ export declare function mapToArray<T>(map: Map<string, T>): T[];
10
+ //# sourceMappingURL=mapToArray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapToArray.d.ts","sourceRoot":"","sources":["../../../src/mapToArray/mapToArray.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAKtD"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 将 Map 转换为数组
3
+ * @param map 输入 Map
4
+ * @returns 转换后的数组
5
+ *
6
+ * @example
7
+ * mapToArray(new Map<string, number>([["a", 1], ["b", 2], ["c", 3]])) // => [1, 2, 3]
8
+ */
9
+ export function mapToArray(map) {
10
+ if (map.size === 0) {
11
+ return [];
12
+ }
13
+ return Array.from(map.values());
14
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"isEmpty.d.ts","sourceRoot":"","sources":["../../../src/utility/isEmpty.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAkB/C"}
1
+ {"version":3,"file":"isEmpty.d.ts","sourceRoot":"","sources":["../../../src/utility/isEmpty.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAkB/C"}
@@ -13,13 +13,13 @@ export function isEmpty(value) {
13
13
  if (value === null || value === undefined) {
14
14
  return true;
15
15
  }
16
- if (typeof value === 'string' || Array.isArray(value)) {
16
+ if (typeof value === "string" || Array.isArray(value)) {
17
17
  return value.length === 0;
18
18
  }
19
19
  if (value instanceof Map || value instanceof Set) {
20
20
  return value.size === 0;
21
21
  }
22
- if (typeof value === 'object') {
22
+ if (typeof value === "object") {
23
23
  return Object.keys(value).length === 0;
24
24
  }
25
25
  return false;
package/dist/index.d.ts CHANGED
@@ -1,14 +1,13 @@
1
1
  /**
2
- * jzlib - 轻量级工具库
3
- * 类似 Lodash 的 JavaScript/TypeScript 工具函数集合
2
+ * jzlib - 轻量级工具库 JavaScript/TypeScript 工具函数集合
4
3
  */
5
- export * from './types';
6
- export * as array from './array';
7
- export * as object from './object';
8
- export * as string from './string';
9
- export * as utility from './utility';
10
- export { chunk, compact, } from './array';
11
- export { pick, omit, } from './object';
12
- export { capitalize, camelCase, } from './string';
13
- export { isString, isNumber, isBoolean, isNull, isUndefined, isNullOrUndefined, isArray, isObject, isFunction, isDate, isRegExp, isMap, isSet, isEmpty, } from './utility';
4
+ export * from "./types";
5
+ export * as array from "./array";
6
+ export * as object from "./object";
7
+ export * as string from "./string";
8
+ export * as utility from "./utility";
9
+ export { chunk, compact, } from "./array";
10
+ export { pick, omit, } from "./object";
11
+ export { capitalize, camelCase, } from "./string";
12
+ export { isString, isNumber, isBoolean, isNull, isUndefined, isNullOrUndefined, isArray, isObject, isFunction, isDate, isRegExp, isMap, isSet, isEmpty, } from "./utility";
14
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,SAAS,CAAC;AAGxB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAGrC,OAAO,EAEL,KAAK,EACL,OAAO,GACR,MAAM,SAAS,CAAC;AAEjB,OAAO,EAEL,IAAI,EACJ,IAAI,GACL,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,UAAU,EACV,SAAS,GACV,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,EACN,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,QAAQ,EACR,UAAU,EACV,MAAM,EACN,QAAQ,EACR,KAAK,EACL,KAAK,EACL,OAAO,GACR,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,SAAS,CAAC;AAGxB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAGrC,OAAO,EAEL,KAAK,EACL,OAAO,GACR,MAAM,SAAS,CAAC;AAEjB,OAAO,EAEL,IAAI,EACJ,IAAI,GACL,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,UAAU,EACV,SAAS,GACV,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,EACN,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,QAAQ,EACR,UAAU,EACV,MAAM,EACN,QAAQ,EACR,KAAK,EACL,KAAK,EACL,OAAO,GACR,MAAM,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * jzlib - 轻量级工具库
4
- * 类似 Lodash 的 JavaScript/TypeScript 工具函数集合
3
+ * jzlib - 轻量级工具库 JavaScript/TypeScript 工具函数集合
5
4
  */
6
5
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
6
  if (k2 === undefined) k2 = k;
@@ -22,23 +21,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
22
21
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
23
22
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
24
23
  };
25
- var __importStar = (this && this.__importStar) || (function () {
26
- var ownKeys = function(o) {
27
- ownKeys = Object.getOwnPropertyNames || function (o) {
28
- var ar = [];
29
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
- return ar;
31
- };
32
- return ownKeys(o);
33
- };
34
- return function (mod) {
35
- if (mod && mod.__esModule) return mod;
36
- var result = {};
37
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
- __setModuleDefault(result, mod);
39
- return result;
40
- };
41
- })();
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
42
31
  Object.defineProperty(exports, "__esModule", { value: true });
43
32
  exports.isEmpty = exports.isSet = exports.isMap = exports.isRegExp = exports.isDate = exports.isFunction = exports.isObject = exports.isArray = exports.isNullOrUndefined = exports.isUndefined = exports.isNull = exports.isBoolean = exports.isNumber = exports.isString = exports.camelCase = exports.capitalize = exports.omit = exports.pick = exports.compact = exports.chunk = exports.utility = exports.string = exports.object = exports.array = void 0;
44
33
  // 类型导出
@@ -0,0 +1,2 @@
1
+ export * from "./mapToArray";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mapToArray/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
@@ -0,0 +1,17 @@
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("./mapToArray"), exports);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 将 Map 转换为数组
3
+ * @param map 输入 Map
4
+ * @returns 转换后的数组
5
+ *
6
+ * @example
7
+ * mapToArray(new Map<string, number>([["a", 1], ["b", 2], ["c", 3]])) // => [1, 2, 3]
8
+ */
9
+ export declare function mapToArray<T>(map: Map<string, T>): T[];
10
+ //# sourceMappingURL=mapToArray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapToArray.d.ts","sourceRoot":"","sources":["../../src/mapToArray/mapToArray.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAKtD"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapToArray = void 0;
4
+ /**
5
+ * 将 Map 转换为数组
6
+ * @param map 输入 Map
7
+ * @returns 转换后的数组
8
+ *
9
+ * @example
10
+ * mapToArray(new Map<string, number>([["a", 1], ["b", 2], ["c", 3]])) // => [1, 2, 3]
11
+ */
12
+ function mapToArray(map) {
13
+ if (map.size === 0) {
14
+ return [];
15
+ }
16
+ return Array.from(map.values());
17
+ }
18
+ exports.mapToArray = mapToArray;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.omit = omit;
3
+ exports.omit = void 0;
4
4
  /**
5
5
  * 从对象中排除指定的属性
6
6
  * @param obj 源对象
@@ -22,3 +22,4 @@ function omit(obj, keys) {
22
22
  }
23
23
  return result;
24
24
  }
25
+ exports.omit = omit;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pick = pick;
3
+ exports.pick = void 0;
4
4
  /**
5
5
  * 从对象中选择指定的属性
6
6
  * @param obj 源对象
@@ -20,3 +20,4 @@ function pick(obj, keys) {
20
20
  }
21
21
  return result;
22
22
  }
23
+ exports.pick = pick;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.camelCase = camelCase;
3
+ exports.camelCase = void 0;
4
4
  /**
5
5
  * 将字符串转换为驼峰式命名法
6
6
  * @param str 输入字符串
@@ -18,3 +18,4 @@ function camelCase(str) {
18
18
  .replace(/[-_\s]+(.)?/g, (_, char) => (char ? char.toUpperCase() : ''))
19
19
  .replace(/^(.)/, (char) => char.toLowerCase());
20
20
  }
21
+ exports.camelCase = camelCase;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.capitalize = capitalize;
3
+ exports.capitalize = void 0;
4
4
  /**
5
5
  * 将字符串首字母转为大写
6
6
  * @param str 输入字符串
@@ -15,3 +15,4 @@ function capitalize(str) {
15
15
  }
16
16
  return str.charAt(0).toUpperCase() + str.slice(1);
17
17
  }
18
+ exports.capitalize = capitalize;
@@ -1 +1 @@
1
- {"version":3,"file":"isEmpty.d.ts","sourceRoot":"","sources":["../../src/utility/isEmpty.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAkB/C"}
1
+ {"version":3,"file":"isEmpty.d.ts","sourceRoot":"","sources":["../../src/utility/isEmpty.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAkB/C"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEmpty = isEmpty;
3
+ exports.isEmpty = void 0;
4
4
  /**
5
5
  * 检查值是否为空
6
6
  * @param value 要检查的值
@@ -16,14 +16,15 @@ function isEmpty(value) {
16
16
  if (value === null || value === undefined) {
17
17
  return true;
18
18
  }
19
- if (typeof value === 'string' || Array.isArray(value)) {
19
+ if (typeof value === "string" || Array.isArray(value)) {
20
20
  return value.length === 0;
21
21
  }
22
22
  if (value instanceof Map || value instanceof Set) {
23
23
  return value.size === 0;
24
24
  }
25
- if (typeof value === 'object') {
25
+ if (typeof value === "object") {
26
26
  return Object.keys(value).length === 0;
27
27
  }
28
28
  return false;
29
29
  }
30
+ exports.isEmpty = isEmpty;
@@ -3,55 +3,56 @@
3
3
  * 检查值是否为指定类型
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isString = isString;
7
- exports.isNumber = isNumber;
8
- exports.isBoolean = isBoolean;
9
- exports.isNull = isNull;
10
- exports.isUndefined = isUndefined;
11
- exports.isNullOrUndefined = isNullOrUndefined;
12
- exports.isArray = isArray;
13
- exports.isObject = isObject;
14
- exports.isFunction = isFunction;
15
- exports.isDate = isDate;
16
- exports.isRegExp = isRegExp;
17
- exports.isMap = isMap;
18
- exports.isSet = isSet;
6
+ exports.isSet = exports.isMap = exports.isRegExp = exports.isDate = exports.isFunction = exports.isObject = exports.isArray = exports.isNullOrUndefined = exports.isUndefined = exports.isNull = exports.isBoolean = exports.isNumber = exports.isString = void 0;
19
7
  function isString(value) {
20
8
  return typeof value === 'string';
21
9
  }
10
+ exports.isString = isString;
22
11
  function isNumber(value) {
23
12
  return typeof value === 'number' && !Number.isNaN(value);
24
13
  }
14
+ exports.isNumber = isNumber;
25
15
  function isBoolean(value) {
26
16
  return typeof value === 'boolean';
27
17
  }
18
+ exports.isBoolean = isBoolean;
28
19
  function isNull(value) {
29
20
  return value === null;
30
21
  }
22
+ exports.isNull = isNull;
31
23
  function isUndefined(value) {
32
24
  return value === undefined;
33
25
  }
26
+ exports.isUndefined = isUndefined;
34
27
  function isNullOrUndefined(value) {
35
28
  return value === null || value === undefined;
36
29
  }
30
+ exports.isNullOrUndefined = isNullOrUndefined;
37
31
  function isArray(value) {
38
32
  return Array.isArray(value);
39
33
  }
34
+ exports.isArray = isArray;
40
35
  function isObject(value) {
41
36
  return value !== null && typeof value === 'object' && !Array.isArray(value);
42
37
  }
38
+ exports.isObject = isObject;
43
39
  function isFunction(value) {
44
40
  return typeof value === 'function';
45
41
  }
42
+ exports.isFunction = isFunction;
46
43
  function isDate(value) {
47
44
  return value instanceof Date;
48
45
  }
46
+ exports.isDate = isDate;
49
47
  function isRegExp(value) {
50
48
  return value instanceof RegExp;
51
49
  }
50
+ exports.isRegExp = isRegExp;
52
51
  function isMap(value) {
53
52
  return value instanceof Map;
54
53
  }
54
+ exports.isMap = isMap;
55
55
  function isSet(value) {
56
56
  return value instanceof Set;
57
57
  }
58
+ exports.isSet = isSet;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jz-toolkit",
3
- "version": "1.0.4",
4
- "description": "一个轻量级的、类似 Lodash 的 JavaScript 工具库",
3
+ "version": "1.0.6",
4
+ "description": "一个轻量级的JavaScript/TypeScript 工具库",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "module": "dist/esm/index.js",
@@ -27,6 +27,11 @@
27
27
  "import": "./dist/esm/object/index.js",
28
28
  "types": "./dist/object/index.d.ts"
29
29
  },
30
+ "./mapToArray": {
31
+ "require": "./dist/mapToArray/index.js",
32
+ "import": "./dist/esm/mapToArray/index.js",
33
+ "types": "./dist/mapToArray/index.d.ts"
34
+ },
30
35
  "./string": {
31
36
  "require": "./dist/string/index.js",
32
37
  "import": "./dist/esm/string/index.js",