@alibarbar/common 1.0.0

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.
Files changed (210) hide show
  1. package/README.md +338 -0
  2. package/dist/algorithm.d.mts +66 -0
  3. package/dist/algorithm.d.ts +66 -0
  4. package/dist/algorithm.js +44 -0
  5. package/dist/algorithm.js.map +1 -0
  6. package/dist/algorithm.mjs +3 -0
  7. package/dist/algorithm.mjs.map +1 -0
  8. package/dist/array.d.mts +139 -0
  9. package/dist/array.d.ts +139 -0
  10. package/dist/array.js +84 -0
  11. package/dist/array.js.map +1 -0
  12. package/dist/array.mjs +3 -0
  13. package/dist/array.mjs.map +1 -0
  14. package/dist/chunk-27UDDVLZ.js +259 -0
  15. package/dist/chunk-27UDDVLZ.js.map +1 -0
  16. package/dist/chunk-2FFSQ573.mjs +138 -0
  17. package/dist/chunk-2FFSQ573.mjs.map +1 -0
  18. package/dist/chunk-4RGXV4SJ.js +106 -0
  19. package/dist/chunk-4RGXV4SJ.js.map +1 -0
  20. package/dist/chunk-56W6YECK.js +374 -0
  21. package/dist/chunk-56W6YECK.js.map +1 -0
  22. package/dist/chunk-5BGSUGTI.mjs +128 -0
  23. package/dist/chunk-5BGSUGTI.mjs.map +1 -0
  24. package/dist/chunk-7E6GELHJ.mjs +302 -0
  25. package/dist/chunk-7E6GELHJ.mjs.map +1 -0
  26. package/dist/chunk-7V5UQXIO.js +89 -0
  27. package/dist/chunk-7V5UQXIO.js.map +1 -0
  28. package/dist/chunk-A4SWQXX7.mjs +484 -0
  29. package/dist/chunk-A4SWQXX7.mjs.map +1 -0
  30. package/dist/chunk-ALDC6LRJ.mjs +85 -0
  31. package/dist/chunk-ALDC6LRJ.mjs.map +1 -0
  32. package/dist/chunk-BHCRFURU.js +491 -0
  33. package/dist/chunk-BHCRFURU.js.map +1 -0
  34. package/dist/chunk-D7CS5EKF.js +110 -0
  35. package/dist/chunk-D7CS5EKF.js.map +1 -0
  36. package/dist/chunk-DYBSRI7V.js +189 -0
  37. package/dist/chunk-DYBSRI7V.js.map +1 -0
  38. package/dist/chunk-F3LAGHPG.js +332 -0
  39. package/dist/chunk-F3LAGHPG.js.map +1 -0
  40. package/dist/chunk-HLDFI7R2.mjs +175 -0
  41. package/dist/chunk-HLDFI7R2.mjs.map +1 -0
  42. package/dist/chunk-HME2N3VY.mjs +354 -0
  43. package/dist/chunk-HME2N3VY.mjs.map +1 -0
  44. package/dist/chunk-I3L42475.js +145 -0
  45. package/dist/chunk-I3L42475.js.map +1 -0
  46. package/dist/chunk-JBLX27WD.mjs +240 -0
  47. package/dist/chunk-JBLX27WD.mjs.map +1 -0
  48. package/dist/chunk-JHZ7M2MR.mjs +133 -0
  49. package/dist/chunk-JHZ7M2MR.mjs.map +1 -0
  50. package/dist/chunk-JK2SE3I2.js +100 -0
  51. package/dist/chunk-JK2SE3I2.js.map +1 -0
  52. package/dist/chunk-JQZBPAPO.js +157 -0
  53. package/dist/chunk-JQZBPAPO.js.map +1 -0
  54. package/dist/chunk-JXYGC2C5.mjs +100 -0
  55. package/dist/chunk-JXYGC2C5.mjs.map +1 -0
  56. package/dist/chunk-KGFTD255.js +104 -0
  57. package/dist/chunk-KGFTD255.js.map +1 -0
  58. package/dist/chunk-LBHBNPNJ.mjs +148 -0
  59. package/dist/chunk-LBHBNPNJ.mjs.map +1 -0
  60. package/dist/chunk-LCXGZISK.js +158 -0
  61. package/dist/chunk-LCXGZISK.js.map +1 -0
  62. package/dist/chunk-LF4CILQS.mjs +87 -0
  63. package/dist/chunk-LF4CILQS.mjs.map +1 -0
  64. package/dist/chunk-MMR6XQNX.js +98 -0
  65. package/dist/chunk-MMR6XQNX.js.map +1 -0
  66. package/dist/chunk-NSSDYX2U.mjs +80 -0
  67. package/dist/chunk-NSSDYX2U.mjs.map +1 -0
  68. package/dist/chunk-O3O67R4I.js +143 -0
  69. package/dist/chunk-O3O67R4I.js.map +1 -0
  70. package/dist/chunk-OX5PLOWB.js +90 -0
  71. package/dist/chunk-OX5PLOWB.js.map +1 -0
  72. package/dist/chunk-PJ7UCTX4.mjs +362 -0
  73. package/dist/chunk-PJ7UCTX4.mjs.map +1 -0
  74. package/dist/chunk-QIBE7GVN.mjs +81 -0
  75. package/dist/chunk-QIBE7GVN.mjs.map +1 -0
  76. package/dist/chunk-QIOC54LQ.mjs +130 -0
  77. package/dist/chunk-QIOC54LQ.mjs.map +1 -0
  78. package/dist/chunk-QV6MIQ7H.mjs +328 -0
  79. package/dist/chunk-QV6MIQ7H.mjs.map +1 -0
  80. package/dist/chunk-TQN37HIN.js +94 -0
  81. package/dist/chunk-TQN37HIN.js.map +1 -0
  82. package/dist/chunk-XJTZDXSR.mjs +94 -0
  83. package/dist/chunk-XJTZDXSR.mjs.map +1 -0
  84. package/dist/chunk-XVUE53T3.js +361 -0
  85. package/dist/chunk-XVUE53T3.js.map +1 -0
  86. package/dist/chunk-Y364QIQH.js +139 -0
  87. package/dist/chunk-Y364QIQH.js.map +1 -0
  88. package/dist/chunk-YXM6Q4JS.mjs +94 -0
  89. package/dist/chunk-YXM6Q4JS.mjs.map +1 -0
  90. package/dist/chunk-ZDMFMUDR.js +309 -0
  91. package/dist/chunk-ZDMFMUDR.js.map +1 -0
  92. package/dist/chunk-ZVJ6NQUM.mjs +82 -0
  93. package/dist/chunk-ZVJ6NQUM.mjs.map +1 -0
  94. package/dist/color.d.mts +74 -0
  95. package/dist/color.d.ts +74 -0
  96. package/dist/color.js +40 -0
  97. package/dist/color.js.map +1 -0
  98. package/dist/color.mjs +3 -0
  99. package/dist/color.mjs.map +1 -0
  100. package/dist/crypto.d.mts +92 -0
  101. package/dist/crypto.d.ts +92 -0
  102. package/dist/crypto.js +60 -0
  103. package/dist/crypto.js.map +1 -0
  104. package/dist/crypto.mjs +3 -0
  105. package/dist/crypto.mjs.map +1 -0
  106. package/dist/data-structure.d.mts +213 -0
  107. package/dist/data-structure.d.ts +213 -0
  108. package/dist/data-structure.js +32 -0
  109. package/dist/data-structure.js.map +1 -0
  110. package/dist/data-structure.mjs +3 -0
  111. package/dist/data-structure.mjs.map +1 -0
  112. package/dist/date.d.mts +108 -0
  113. package/dist/date.d.ts +108 -0
  114. package/dist/date.js +72 -0
  115. package/dist/date.js.map +1 -0
  116. package/dist/date.mjs +3 -0
  117. package/dist/date.mjs.map +1 -0
  118. package/dist/dom.d.mts +92 -0
  119. package/dist/dom.d.ts +92 -0
  120. package/dist/dom.js +56 -0
  121. package/dist/dom.js.map +1 -0
  122. package/dist/dom.mjs +3 -0
  123. package/dist/dom.mjs.map +1 -0
  124. package/dist/file.d.mts +44 -0
  125. package/dist/file.d.ts +44 -0
  126. package/dist/file.js +32 -0
  127. package/dist/file.js.map +1 -0
  128. package/dist/file.mjs +3 -0
  129. package/dist/file.mjs.map +1 -0
  130. package/dist/i18n.d.mts +77 -0
  131. package/dist/i18n.d.ts +77 -0
  132. package/dist/i18n.js +40 -0
  133. package/dist/i18n.js.map +1 -0
  134. package/dist/i18n.mjs +3 -0
  135. package/dist/i18n.mjs.map +1 -0
  136. package/dist/index.d.mts +155 -0
  137. package/dist/index.d.ts +155 -0
  138. package/dist/index.js +839 -0
  139. package/dist/index.js.map +1 -0
  140. package/dist/index.mjs +22 -0
  141. package/dist/index.mjs.map +1 -0
  142. package/dist/network.d.mts +47 -0
  143. package/dist/network.d.ts +47 -0
  144. package/dist/network.js +28 -0
  145. package/dist/network.js.map +1 -0
  146. package/dist/network.mjs +3 -0
  147. package/dist/network.mjs.map +1 -0
  148. package/dist/number.d.mts +100 -0
  149. package/dist/number.d.ts +100 -0
  150. package/dist/number.js +56 -0
  151. package/dist/number.js.map +1 -0
  152. package/dist/number.mjs +3 -0
  153. package/dist/number.mjs.map +1 -0
  154. package/dist/object.d.mts +132 -0
  155. package/dist/object.d.ts +132 -0
  156. package/dist/object.js +80 -0
  157. package/dist/object.js.map +1 -0
  158. package/dist/object.mjs +3 -0
  159. package/dist/object.mjs.map +1 -0
  160. package/dist/performance.d.mts +85 -0
  161. package/dist/performance.d.ts +85 -0
  162. package/dist/performance.js +40 -0
  163. package/dist/performance.js.map +1 -0
  164. package/dist/performance.mjs +3 -0
  165. package/dist/performance.mjs.map +1 -0
  166. package/dist/storage.d.mts +176 -0
  167. package/dist/storage.d.ts +176 -0
  168. package/dist/storage.js +33 -0
  169. package/dist/storage.js.map +1 -0
  170. package/dist/storage.mjs +4 -0
  171. package/dist/storage.mjs.map +1 -0
  172. package/dist/string.d.mts +105 -0
  173. package/dist/string.d.ts +105 -0
  174. package/dist/string.js +68 -0
  175. package/dist/string.js.map +1 -0
  176. package/dist/string.mjs +3 -0
  177. package/dist/string.mjs.map +1 -0
  178. package/dist/tracking.d.mts +182 -0
  179. package/dist/tracking.d.ts +182 -0
  180. package/dist/tracking.js +52 -0
  181. package/dist/tracking.js.map +1 -0
  182. package/dist/tracking.mjs +3 -0
  183. package/dist/tracking.mjs.map +1 -0
  184. package/dist/transform.d.mts +53 -0
  185. package/dist/transform.d.ts +53 -0
  186. package/dist/transform.js +32 -0
  187. package/dist/transform.js.map +1 -0
  188. package/dist/transform.mjs +3 -0
  189. package/dist/transform.mjs.map +1 -0
  190. package/dist/upload-DzlQtUBc.d.mts +202 -0
  191. package/dist/upload-DzlQtUBc.d.ts +202 -0
  192. package/dist/upload.d.mts +1 -0
  193. package/dist/upload.d.ts +1 -0
  194. package/dist/upload.js +17 -0
  195. package/dist/upload.js.map +1 -0
  196. package/dist/upload.mjs +4 -0
  197. package/dist/upload.mjs.map +1 -0
  198. package/dist/url.d.mts +82 -0
  199. package/dist/url.d.ts +82 -0
  200. package/dist/url.js +44 -0
  201. package/dist/url.js.map +1 -0
  202. package/dist/url.mjs +3 -0
  203. package/dist/url.mjs.map +1 -0
  204. package/dist/validation.d.mts +83 -0
  205. package/dist/validation.d.ts +83 -0
  206. package/dist/validation.js +60 -0
  207. package/dist/validation.js.map +1 -0
  208. package/dist/validation.mjs +3 -0
  209. package/dist/validation.mjs.map +1 -0
  210. package/package.json +170 -0
@@ -0,0 +1,139 @@
1
+ /**
2
+ * 数组工具函数
3
+ */
4
+ /**
5
+ * 数组去重
6
+ * @param arr - 输入数组
7
+ * @returns 去重后的数组
8
+ */
9
+ declare function unique<T>(arr: T[]): T[];
10
+ /**
11
+ * 数组分组
12
+ * @param arr - 输入数组
13
+ * @param keyFn - 分组键函数或属性名
14
+ * @returns 分组后的对象
15
+ */
16
+ declare function groupBy<T, K extends string | number>(arr: T[], keyFn: ((item: T) => K) | string): Record<K, T[]>;
17
+ /**
18
+ * 数组分块
19
+ * @param arr - 输入数组
20
+ * @param size - 每块大小
21
+ * @returns 分块后的二维数组
22
+ */
23
+ declare function chunk<T>(arr: T[], size: number): T[][];
24
+ /**
25
+ * 数组扁平化
26
+ * @param arr - 输入数组
27
+ * @param depth - 扁平化深度,默认为 1
28
+ * @returns 扁平化后的数组
29
+ */
30
+ declare function flatten<T>(arr: (T | T[])[], depth?: number): T[];
31
+ /**
32
+ * 数组随机打乱(Fisher-Yates算法)
33
+ * @param arr - 输入数组
34
+ * @returns 打乱后的新数组
35
+ */
36
+ declare function shuffle<T>(arr: T[]): T[];
37
+ /**
38
+ * 随机取样
39
+ * @param arr - 输入数组
40
+ * @param count - 取样数量,默认为 1。当 count=1 时返回单个元素,否则返回数组
41
+ * @returns 随机取样的数组或单个元素
42
+ */
43
+ declare function sample<T>(arr: T[]): T;
44
+ declare function sample<T>(arr: T[], count: number): T | T[];
45
+ /**
46
+ * 数组差集(在arr1中但不在arr2中的元素)
47
+ * @param arr1 - 第一个数组
48
+ * @param arr2 - 第二个数组
49
+ * @returns 差集数组
50
+ */
51
+ declare function difference<T>(arr1: T[], arr2: T[]): T[];
52
+ /**
53
+ * 数组交集
54
+ * @param arr1 - 第一个数组
55
+ * @param arr2 - 第二个数组
56
+ * @returns 交集数组
57
+ */
58
+ declare function intersection<T>(arr1: T[], arr2: T[]): T[];
59
+ /**
60
+ * 数组并集
61
+ * @param arr1 - 第一个数组
62
+ * @param arr2 - 第二个数组
63
+ * @returns 并集数组
64
+ */
65
+ declare function union<T>(arr1: T[], arr2: T[]): T[];
66
+ /**
67
+ * 按属性排序
68
+ * @param arr - 输入数组
69
+ * @param keyFn - 获取排序键的函数或属性名
70
+ * @param order - 排序顺序,'asc' 或 'desc',默认为 'asc'
71
+ * @returns 排序后的新数组
72
+ */
73
+ declare function sortBy<T, K extends string | number>(arr: T[], keyFn: ((item: T) => K) | string, order?: 'asc' | 'desc'): T[];
74
+ /**
75
+ * 按条件查找索引
76
+ * @param arr - 输入数组
77
+ * @param predicate - 条件函数
78
+ * @returns 找到的索引,未找到返回 -1
79
+ */
80
+ declare function findIndexBy<T>(arr: T[], predicate: (item: T) => boolean): number;
81
+ /**
82
+ * 数组分割(满足条件/不满足条件)
83
+ * @param arr - 输入数组
84
+ * @param predicate - 条件函数
85
+ * @returns 包含两个数组的元组:[满足条件的数组, 不满足条件的数组]
86
+ */
87
+ declare function partition<T>(arr: T[], predicate: (item: T) => boolean): [T[], T[]];
88
+ /**
89
+ * 数组压缩(将多个数组合并成元组数组)
90
+ * @param arrays - 要压缩的数组
91
+ * @returns 压缩后的元组数组
92
+ */
93
+ declare function zip<T extends readonly unknown[]>(...arrays: T): Array<{
94
+ [K in keyof T]: T[K] extends readonly (infer U)[] ? U : never;
95
+ }>;
96
+ /**
97
+ * 数组解压(将元组数组拆分成多个数组)
98
+ * @param array - 要解压的数组
99
+ * @returns 解压后的数组元组
100
+ */
101
+ declare function unzip<T extends readonly unknown[]>(array: Array<{
102
+ [K in keyof T]: T[number] extends readonly (infer U)[] ? U : never;
103
+ }>): T;
104
+ /**
105
+ * 移除假值(null, undefined, false, 0, '')
106
+ * @param arr - 输入数组
107
+ * @returns 移除假值后的数组
108
+ */
109
+ declare function compact<T>(arr: (T | null | undefined | false | 0 | '')[]): T[];
110
+ /**
111
+ * 取前N个元素
112
+ * @param arr - 输入数组
113
+ * @param n - 要取的元素数量
114
+ * @returns 前N个元素的数组
115
+ */
116
+ declare function take<T>(arr: T[], n: number): T[];
117
+ /**
118
+ * 跳过前N个元素
119
+ * @param arr - 输入数组
120
+ * @param n - 要跳过的元素数量
121
+ * @returns 跳过后的数组
122
+ */
123
+ declare function drop<T>(arr: T[], n: number): T[];
124
+ /**
125
+ * 条件取元素(直到条件不满足)
126
+ * @param arr - 输入数组
127
+ * @param predicate - 条件函数
128
+ * @returns 满足条件的连续元素数组
129
+ */
130
+ declare function takeWhile<T>(arr: T[], predicate: (item: T) => boolean): T[];
131
+ /**
132
+ * 条件跳过元素(直到条件不满足)
133
+ * @param arr - 输入数组
134
+ * @param predicate - 条件函数
135
+ * @returns 跳过后的数组
136
+ */
137
+ declare function dropWhile<T>(arr: T[], predicate: (item: T) => boolean): T[];
138
+
139
+ export { chunk, compact, difference, drop, dropWhile, findIndexBy, flatten, groupBy, intersection, partition, sample, shuffle, sortBy, take, takeWhile, union, unique, unzip, zip };
package/dist/array.js ADDED
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+
3
+ var chunkLCXGZISK_js = require('./chunk-LCXGZISK.js');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "chunk", {
8
+ enumerable: true,
9
+ get: function () { return chunkLCXGZISK_js.chunk; }
10
+ });
11
+ Object.defineProperty(exports, "compact", {
12
+ enumerable: true,
13
+ get: function () { return chunkLCXGZISK_js.compact; }
14
+ });
15
+ Object.defineProperty(exports, "difference", {
16
+ enumerable: true,
17
+ get: function () { return chunkLCXGZISK_js.difference; }
18
+ });
19
+ Object.defineProperty(exports, "drop", {
20
+ enumerable: true,
21
+ get: function () { return chunkLCXGZISK_js.drop; }
22
+ });
23
+ Object.defineProperty(exports, "dropWhile", {
24
+ enumerable: true,
25
+ get: function () { return chunkLCXGZISK_js.dropWhile; }
26
+ });
27
+ Object.defineProperty(exports, "findIndexBy", {
28
+ enumerable: true,
29
+ get: function () { return chunkLCXGZISK_js.findIndexBy; }
30
+ });
31
+ Object.defineProperty(exports, "flatten", {
32
+ enumerable: true,
33
+ get: function () { return chunkLCXGZISK_js.flatten; }
34
+ });
35
+ Object.defineProperty(exports, "groupBy", {
36
+ enumerable: true,
37
+ get: function () { return chunkLCXGZISK_js.groupBy; }
38
+ });
39
+ Object.defineProperty(exports, "intersection", {
40
+ enumerable: true,
41
+ get: function () { return chunkLCXGZISK_js.intersection; }
42
+ });
43
+ Object.defineProperty(exports, "partition", {
44
+ enumerable: true,
45
+ get: function () { return chunkLCXGZISK_js.partition; }
46
+ });
47
+ Object.defineProperty(exports, "sample", {
48
+ enumerable: true,
49
+ get: function () { return chunkLCXGZISK_js.sample; }
50
+ });
51
+ Object.defineProperty(exports, "shuffle", {
52
+ enumerable: true,
53
+ get: function () { return chunkLCXGZISK_js.shuffle; }
54
+ });
55
+ Object.defineProperty(exports, "sortBy", {
56
+ enumerable: true,
57
+ get: function () { return chunkLCXGZISK_js.sortBy; }
58
+ });
59
+ Object.defineProperty(exports, "take", {
60
+ enumerable: true,
61
+ get: function () { return chunkLCXGZISK_js.take; }
62
+ });
63
+ Object.defineProperty(exports, "takeWhile", {
64
+ enumerable: true,
65
+ get: function () { return chunkLCXGZISK_js.takeWhile; }
66
+ });
67
+ Object.defineProperty(exports, "union", {
68
+ enumerable: true,
69
+ get: function () { return chunkLCXGZISK_js.union; }
70
+ });
71
+ Object.defineProperty(exports, "unique", {
72
+ enumerable: true,
73
+ get: function () { return chunkLCXGZISK_js.unique; }
74
+ });
75
+ Object.defineProperty(exports, "unzip", {
76
+ enumerable: true,
77
+ get: function () { return chunkLCXGZISK_js.unzip; }
78
+ });
79
+ Object.defineProperty(exports, "zip", {
80
+ enumerable: true,
81
+ get: function () { return chunkLCXGZISK_js.zip; }
82
+ });
83
+ //# sourceMappingURL=array.js.map
84
+ //# sourceMappingURL=array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"array.js"}
package/dist/array.mjs ADDED
@@ -0,0 +1,3 @@
1
+ export { chunk, compact, difference, drop, dropWhile, findIndexBy, flatten, groupBy, intersection, partition, sample, shuffle, sortBy, take, takeWhile, union, unique, unzip, zip } from './chunk-2FFSQ573.mjs';
2
+ //# sourceMappingURL=array.mjs.map
3
+ //# sourceMappingURL=array.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"array.mjs"}
@@ -0,0 +1,259 @@
1
+ 'use strict';
2
+
3
+ // src/core/object.ts
4
+ function deepClone(obj) {
5
+ if (obj === null || typeof obj !== "object") {
6
+ return obj;
7
+ }
8
+ if (obj instanceof Date) {
9
+ return new Date(obj.getTime());
10
+ }
11
+ if (obj instanceof RegExp) {
12
+ return new RegExp(obj.source, obj.flags);
13
+ }
14
+ if (Array.isArray(obj)) {
15
+ return obj.map((item) => deepClone(item));
16
+ }
17
+ if (obj instanceof Map) {
18
+ const clonedMap = /* @__PURE__ */ new Map();
19
+ obj.forEach((value, key) => {
20
+ clonedMap.set(deepClone(key), deepClone(value));
21
+ });
22
+ return clonedMap;
23
+ }
24
+ if (obj instanceof Set) {
25
+ const clonedSet = /* @__PURE__ */ new Set();
26
+ obj.forEach((value) => {
27
+ clonedSet.add(deepClone(value));
28
+ });
29
+ return clonedSet;
30
+ }
31
+ if (typeof obj === "object") {
32
+ const clonedObj = {};
33
+ for (const key in obj) {
34
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
35
+ clonedObj[key] = deepClone(obj[key]);
36
+ }
37
+ }
38
+ return clonedObj;
39
+ }
40
+ return obj;
41
+ }
42
+ function merge(target, ...sources) {
43
+ return Object.assign({}, target, ...sources);
44
+ }
45
+ function deepMerge(target, ...sources) {
46
+ if (!sources.length) return target;
47
+ const source = sources.shift();
48
+ if (!source) {
49
+ return deepMerge(target, ...sources);
50
+ }
51
+ if (isObject(target) && isObject(source)) {
52
+ for (const key in source) {
53
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
54
+ const sourceValue = source[key];
55
+ const targetValue = target[key];
56
+ if (isObject(sourceValue) && isObject(targetValue)) {
57
+ target[key] = deepMerge(
58
+ targetValue,
59
+ sourceValue
60
+ );
61
+ } else if (sourceValue !== void 0) {
62
+ target[key] = sourceValue;
63
+ }
64
+ }
65
+ }
66
+ }
67
+ return deepMerge(target, ...sources);
68
+ }
69
+ function isObject(item) {
70
+ return item !== null && typeof item === "object" && !Array.isArray(item) && !(item instanceof Date) && !(item instanceof RegExp) && !(item instanceof Map) && !(item instanceof Set);
71
+ }
72
+ function get(obj, path, defaultValue) {
73
+ if (!obj || typeof obj !== "object") {
74
+ return defaultValue;
75
+ }
76
+ const keys2 = Array.isArray(path) ? path : path.split(".");
77
+ if (keys2.length === 0) {
78
+ return defaultValue;
79
+ }
80
+ let result = obj;
81
+ for (const key of keys2) {
82
+ if (result == null || typeof result !== "object" || Array.isArray(result)) {
83
+ return defaultValue;
84
+ }
85
+ const record = result;
86
+ if (!(key in record)) {
87
+ return defaultValue;
88
+ }
89
+ result = record[key];
90
+ }
91
+ return result !== void 0 ? result : defaultValue;
92
+ }
93
+ function set(obj, path, value) {
94
+ const keys2 = Array.isArray(path) ? path : path.split(".");
95
+ if (keys2.length === 0) return obj;
96
+ const result = deepClone(obj);
97
+ let current = result;
98
+ for (let i = 0; i < keys2.length - 1; i++) {
99
+ const key = keys2[i];
100
+ if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
101
+ current[key] = {};
102
+ }
103
+ current = current[key];
104
+ }
105
+ current[keys2[keys2.length - 1]] = value;
106
+ return result;
107
+ }
108
+ function pick(obj, keys2) {
109
+ const result = {};
110
+ keys2.forEach((key) => {
111
+ if (key in obj) {
112
+ result[key] = obj[key];
113
+ }
114
+ });
115
+ return result;
116
+ }
117
+ function omit(obj, keys2) {
118
+ const result = { ...obj };
119
+ keys2.forEach((key) => {
120
+ delete result[key];
121
+ });
122
+ return result;
123
+ }
124
+ function keys(obj, deep = false) {
125
+ if (!deep) return Object.keys(obj);
126
+ const result = [];
127
+ const traverse = (current, prefix = "") => {
128
+ Object.keys(current).forEach((key) => {
129
+ const fullKey = prefix ? `${prefix}.${key}` : key;
130
+ result.push(fullKey);
131
+ const value = current[key];
132
+ if (value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp)) {
133
+ traverse(value, fullKey);
134
+ }
135
+ });
136
+ };
137
+ traverse(obj);
138
+ return result;
139
+ }
140
+ function values(obj, deep = false) {
141
+ if (!deep) return Object.values(obj);
142
+ const result = [];
143
+ const traverse = (current) => {
144
+ Object.values(current).forEach((value) => {
145
+ if (value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp)) {
146
+ traverse(value);
147
+ } else {
148
+ result.push(value);
149
+ }
150
+ });
151
+ };
152
+ traverse(obj);
153
+ return result;
154
+ }
155
+ function mapKeys(obj, fn) {
156
+ const result = {};
157
+ Object.keys(obj).forEach((key) => {
158
+ const newKey = fn(key, obj[key]);
159
+ result[newKey] = obj[key];
160
+ });
161
+ return result;
162
+ }
163
+ function mapValues(obj, fn) {
164
+ const result = {};
165
+ Object.keys(obj).forEach((key) => {
166
+ result[key] = fn(obj[key], key);
167
+ });
168
+ return result;
169
+ }
170
+ function invert(obj) {
171
+ const result = {};
172
+ Object.keys(obj).forEach((key) => {
173
+ result[String(obj[key])] = key;
174
+ });
175
+ return result;
176
+ }
177
+ function defaults(obj, ...defaults2) {
178
+ const result = { ...obj };
179
+ defaults2.reverse().forEach((defaultObj) => {
180
+ Object.keys(defaultObj).forEach((key) => {
181
+ const typedKey = key;
182
+ if (!(typedKey in result) || result[typedKey] === void 0) {
183
+ result[typedKey] = defaultObj[typedKey];
184
+ }
185
+ });
186
+ });
187
+ return result;
188
+ }
189
+ function isEmptyObject(obj) {
190
+ return Object.keys(obj).length === 0;
191
+ }
192
+ function isEqual(obj1, obj2) {
193
+ if (obj1 === obj2) return true;
194
+ if (obj1 === null || obj2 === null) return false;
195
+ if (typeof obj1 !== "object" || typeof obj2 !== "object") return false;
196
+ if (obj1 instanceof Date && obj2 instanceof Date) {
197
+ return obj1.getTime() === obj2.getTime();
198
+ }
199
+ if (Array.isArray(obj1) && Array.isArray(obj2)) {
200
+ if (obj1.length !== obj2.length) return false;
201
+ return obj1.every((item, index) => isEqual(item, obj2[index]));
202
+ }
203
+ if (Array.isArray(obj1) || Array.isArray(obj2)) return false;
204
+ const keys1 = Object.keys(obj1);
205
+ const keys2 = Object.keys(obj2);
206
+ if (keys1.length !== keys2.length) return false;
207
+ return keys1.every((key) => {
208
+ const val1 = obj1[key];
209
+ const val2 = obj2[key];
210
+ return isEqual(val1, val2);
211
+ });
212
+ }
213
+ function transform(obj, iteratee, accumulator = {}) {
214
+ Object.keys(obj).forEach((key) => {
215
+ iteratee(accumulator, obj[key], key);
216
+ });
217
+ return accumulator;
218
+ }
219
+ function pickBy(obj, predicate) {
220
+ const result = {};
221
+ Object.keys(obj).forEach((key) => {
222
+ const typedKey = key;
223
+ if (predicate(obj[typedKey], key)) {
224
+ result[typedKey] = obj[typedKey];
225
+ }
226
+ });
227
+ return result;
228
+ }
229
+ function omitBy(obj, predicate) {
230
+ const result = {};
231
+ Object.keys(obj).forEach((key) => {
232
+ const typedKey = key;
233
+ if (!predicate(obj[typedKey], key)) {
234
+ result[typedKey] = obj[typedKey];
235
+ }
236
+ });
237
+ return result;
238
+ }
239
+
240
+ exports.deepClone = deepClone;
241
+ exports.deepMerge = deepMerge;
242
+ exports.defaults = defaults;
243
+ exports.get = get;
244
+ exports.invert = invert;
245
+ exports.isEmptyObject = isEmptyObject;
246
+ exports.isEqual = isEqual;
247
+ exports.keys = keys;
248
+ exports.mapKeys = mapKeys;
249
+ exports.mapValues = mapValues;
250
+ exports.merge = merge;
251
+ exports.omit = omit;
252
+ exports.omitBy = omitBy;
253
+ exports.pick = pick;
254
+ exports.pickBy = pickBy;
255
+ exports.set = set;
256
+ exports.transform = transform;
257
+ exports.values = values;
258
+ //# sourceMappingURL=chunk-27UDDVLZ.js.map
259
+ //# sourceMappingURL=chunk-27UDDVLZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/object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AA,MAAA,CAAO,IAAA,CAAK,GAAG,CAAA,CAAE,OAAA,CAAQ,CAAA,GAAA,KAAO;AAC9B,IAAA,MAAM,QAAA,GAAW,GAAA;AACjB,IAAA,IAAI,SAAA,CAAU,GAAA,CAAI,QAAQ,CAAA,EAAG,GAAG,CAAA,EAAG;AACjC,MAAA,MAAA,CAAO,QAAQ,CAAA,GAAI,GAAA,CAAI,QAAQ,CAAA;AAAA,IACjC;AAAA,EACF,CAAC,CAAA;AACD,EAAA,OAAO,MAAA;AACT;AAQO,SAAS,MAAA,CACd,KACA,SAAA,EACY;AACZ,EAAA,MAAM,SAAqB,EAAC;AAC5B,EAAA,MAAA,CAAO,IAAA,CAAK,GAAG,CAAA,CAAE,OAAA,CAAQ,CAAA,GAAA,KAAO;AAC9B,IAAA,MAAM,QAAA,GAAW,GAAA;AACjB,IAAA,IAAI,CAAC,SAAA,CAAU,GAAA,CAAI,QAAQ,CAAA,EAAG,GAAG,CAAA,EAAG;AAClC,MAAA,MAAA,CAAO,QAAQ,CAAA,GAAI,GAAA,CAAI,QAAQ,CAAA;AAAA,IACjC;AAAA,EACF,CAAC,CAAA;AACD,EAAA,OAAO,MAAA;AACT","file":"chunk-27UDDVLZ.js","sourcesContent":["/**\n * 对象工具函数\n */\n\n/**\n * 深拷贝对象\n * 支持 Date、Array、RegExp、Map、Set 等特殊类型\n * @param obj - 输入对象\n * @returns 深拷贝后的对象\n */\nexport function deepClone<T>(obj: T): T {\n // 处理 null 和基本类型\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n // 处理 Date\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as unknown as T;\n }\n\n // 处理 RegExp\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as unknown as T;\n }\n\n // 处理 Array\n if (Array.isArray(obj)) {\n return obj.map(item => deepClone(item)) as unknown as T;\n }\n\n // 处理 Map\n if (obj instanceof Map) {\n const clonedMap = new Map();\n obj.forEach((value, key) => {\n clonedMap.set(deepClone(key), deepClone(value));\n });\n return clonedMap as unknown as T;\n }\n\n // 处理 Set\n if (obj instanceof Set) {\n const clonedSet = new Set();\n obj.forEach(value => {\n clonedSet.add(deepClone(value));\n });\n return clonedSet as unknown as T;\n }\n\n // 处理普通对象\n if (typeof obj === 'object') {\n const clonedObj = {} as T;\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n clonedObj[key] = deepClone(obj[key]);\n }\n }\n return clonedObj;\n }\n\n return obj;\n}\n\n/**\n * 对象合并\n * @param target - 目标对象\n * @param sources - 源对象数组\n * @returns 合并后的对象\n */\nexport function merge<T extends Record<string, unknown>>(target: T, ...sources: Partial<T>[]): T {\n return Object.assign({}, target, ...sources);\n}\n\n/**\n * 深合并对象\n * @param target - 目标对象\n * @param sources - 源对象数组\n * @returns 深合并后的对象\n */\nexport function deepMerge<T extends Record<string, unknown>>(\n target: T,\n ...sources: Partial<T>[]\n): T {\n if (!sources.length) return target;\n const source = sources.shift();\n\n if (!source) {\n return deepMerge(target, ...sources);\n }\n\n if (isObject(target) && isObject(source)) {\n for (const key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n const sourceValue = source[key];\n const targetValue = target[key];\n\n if (isObject(sourceValue) && isObject(targetValue)) {\n // 递归合并嵌套对象\n target[key] = deepMerge(\n targetValue as Record<string, unknown>,\n sourceValue as Record<string, unknown>\n ) as T[Extract<keyof T, string>];\n } else if (sourceValue !== undefined) {\n // 直接赋值(包括 null)\n target[key] = sourceValue as T[Extract<keyof T, string>];\n }\n }\n }\n }\n\n return deepMerge(target, ...sources);\n}\n\n/**\n * 判断是否为普通对象(非 null、非数组、非 Date 等)\n */\nfunction isObject(item: unknown): item is Record<string, unknown> {\n return (\n item !== null &&\n typeof item === 'object' &&\n !Array.isArray(item) &&\n !(item instanceof Date) &&\n !(item instanceof RegExp) &&\n !(item instanceof Map) &&\n !(item instanceof Set)\n );\n}\n\n/**\n * 获取对象嵌套属性值\n * @param obj - 对象\n * @param path - 属性路径,如 'a.b.c' 或 ['a', 'b', 'c']\n * @param defaultValue - 默认值\n * @returns 属性值\n */\nexport function get<T = unknown>(\n obj: Record<string, unknown>,\n path: string | string[],\n defaultValue?: T\n): T | undefined {\n if (!obj || typeof obj !== 'object') {\n return defaultValue;\n }\n\n const keys = Array.isArray(path) ? path : path.split('.');\n if (keys.length === 0) {\n return defaultValue;\n }\n\n let result: unknown = obj;\n\n for (const key of keys) {\n if (result == null || typeof result !== 'object' || Array.isArray(result)) {\n return defaultValue;\n }\n\n // 使用类型断言访问属性\n const record = result as Record<string, unknown>;\n if (!(key in record)) {\n return defaultValue;\n }\n\n result = record[key];\n }\n\n return result !== undefined ? (result as T) : defaultValue;\n}\n\n/**\n * 设置嵌套属性值\n * @param obj - 对象\n * @param path - 属性路径,如 'a.b.c' 或 ['a', 'b', 'c']\n * @param value - 要设置的值\n * @returns 设置后的新对象(不修改原对象)\n */\nexport function set<T extends Record<string, unknown>>(\n obj: T,\n path: string | string[],\n value: unknown\n): T {\n const keys = Array.isArray(path) ? path : path.split('.');\n if (keys.length === 0) return obj;\n\n const result = deepClone(obj);\n let current: Record<string, unknown> = result;\n\n for (let i = 0; i < keys.length - 1; i++) {\n const key = keys[i];\n if (!(key in current) || typeof current[key] !== 'object' || current[key] === null) {\n current[key] = {};\n }\n current = current[key] as Record<string, unknown>;\n }\n\n current[keys[keys.length - 1]] = value;\n return result;\n}\n\n/**\n * 选择指定属性\n * @param obj - 对象\n * @param keys - 要选择的属性键数组\n * @returns 包含指定属性的新对象\n */\nexport function pick<T extends Record<string, unknown>, K extends keyof T>(\n obj: T,\n keys: K[]\n): Pick<T, K> {\n const result = {} as Pick<T, K>;\n keys.forEach(key => {\n if (key in obj) {\n result[key] = obj[key];\n }\n });\n return result;\n}\n\n/**\n * 排除指定属性\n * @param obj - 对象\n * @param keys - 要排除的属性键数组\n * @returns 排除指定属性后的新对象\n */\nexport function omit<T extends Record<string, unknown>, K extends keyof T>(\n obj: T,\n keys: K[]\n): Omit<T, K> {\n const result = { ...obj };\n keys.forEach(key => {\n delete result[key];\n });\n return result;\n}\n\n/**\n * 获取所有键(支持深度)\n * @param obj - 对象\n * @param deep - 是否深度获取,默认为 false\n * @returns 键数组\n */\nexport function keys<T extends Record<string, unknown>>(obj: T, deep = false): string[] {\n if (!deep) return Object.keys(obj);\n const result: string[] = [];\n const traverse = (current: Record<string, unknown>, prefix = ''): void => {\n Object.keys(current).forEach(key => {\n const fullKey = prefix ? `${prefix}.${key}` : key;\n result.push(fullKey);\n const value = current[key];\n if (\n value !== null &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n !(value instanceof Date) &&\n !(value instanceof RegExp)\n ) {\n traverse(value as Record<string, unknown>, fullKey);\n }\n });\n };\n traverse(obj);\n return result;\n}\n\n/**\n * 获取所有值(支持深度)\n * @param obj - 对象\n * @param deep - 是否深度获取,默认为 false\n * @returns 值数组\n */\nexport function values<T extends Record<string, unknown>>(obj: T, deep = false): unknown[] {\n if (!deep) return Object.values(obj);\n const result: unknown[] = [];\n const traverse = (current: Record<string, unknown>): void => {\n Object.values(current).forEach(value => {\n if (\n value !== null &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n !(value instanceof Date) &&\n !(value instanceof RegExp)\n ) {\n traverse(value as Record<string, unknown>);\n } else {\n result.push(value);\n }\n });\n };\n traverse(obj);\n return result;\n}\n\n/**\n * 键映射\n * @param obj - 对象\n * @param fn - 键转换函数\n * @returns 键映射后的新对象\n */\nexport function mapKeys<T extends Record<string, unknown>>(\n obj: T,\n fn: (key: string, value: unknown) => string\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n Object.keys(obj).forEach(key => {\n const newKey = fn(key, obj[key]);\n result[newKey] = obj[key];\n });\n return result;\n}\n\n/**\n * 值映射\n * @param obj - 对象\n * @param fn - 值转换函数\n * @returns 值映射后的新对象\n */\nexport function mapValues<T extends Record<string, unknown>, R>(\n obj: T,\n fn: (value: unknown, key: string) => R\n): Record<string, R> {\n const result: Record<string, R> = {};\n Object.keys(obj).forEach(key => {\n result[key] = fn(obj[key], key);\n });\n return result;\n}\n\n/**\n * 键值反转\n * @param obj - 对象\n * @returns 键值反转后的新对象\n */\nexport function invert<T extends Record<string, string | number>>(obj: T): Record<string, string> {\n const result: Record<string, string> = {};\n Object.keys(obj).forEach(key => {\n result[String(obj[key])] = key;\n });\n return result;\n}\n\n/**\n * 设置默认值\n * @param obj - 对象\n * @param defaults - 默认值对象\n * @returns 合并默认值后的新对象\n */\nexport function defaults<T extends Record<string, unknown>>(\n obj: Partial<T>,\n ...defaults: Partial<T>[]\n): T {\n const result = { ...obj } as T;\n defaults.reverse().forEach(defaultObj => {\n Object.keys(defaultObj).forEach(key => {\n const typedKey = key as Extract<keyof T, string>;\n if (!(typedKey in result) || result[typedKey] === undefined) {\n result[typedKey] = defaultObj[typedKey] as T[Extract<keyof T, string>];\n }\n });\n });\n return result;\n}\n\n/**\n * 判断对象是否为空\n * @param obj - 对象\n * @returns 是否为空\n */\nexport function isEmptyObject(obj: Record<string, unknown>): boolean {\n return Object.keys(obj).length === 0;\n}\n\n/**\n * 深度比较两个对象\n * @param obj1 - 第一个对象\n * @param obj2 - 第二个对象\n * @returns 是否相等\n */\nexport function isEqual<T>(obj1: T, obj2: T): boolean {\n if (obj1 === obj2) return true;\n if (obj1 === null || obj2 === null) return false;\n if (typeof obj1 !== 'object' || typeof obj2 !== 'object') return false;\n\n if (obj1 instanceof Date && obj2 instanceof Date) {\n return obj1.getTime() === obj2.getTime();\n }\n\n if (Array.isArray(obj1) && Array.isArray(obj2)) {\n if (obj1.length !== obj2.length) return false;\n return obj1.every((item, index) => isEqual(item, obj2[index]));\n }\n\n if (Array.isArray(obj1) || Array.isArray(obj2)) return false;\n\n const keys1 = Object.keys(obj1 as Record<string, unknown>);\n const keys2 = Object.keys(obj2 as Record<string, unknown>);\n\n if (keys1.length !== keys2.length) return false;\n\n return keys1.every(key => {\n const val1 = (obj1 as Record<string, unknown>)[key];\n const val2 = (obj2 as Record<string, unknown>)[key];\n return isEqual(val1, val2);\n });\n}\n\n/**\n * 对象转换\n * @param obj - 对象\n * @param iteratee - 转换函数\n * @param accumulator - 累加器,默认为空对象\n * @returns 转换后的对象\n */\nexport function transform<T extends Record<string, unknown>, R extends Record<string, unknown>>(\n obj: T,\n iteratee: (result: R, value: unknown, key: string) => void,\n accumulator: R = {} as R\n): R {\n Object.keys(obj).forEach(key => {\n iteratee(accumulator, obj[key], key);\n });\n return accumulator;\n}\n\n/**\n * 条件选择属性\n * @param obj - 对象\n * @param predicate - 条件函数\n * @returns 满足条件的属性组成的新对象\n */\nexport function pickBy<T extends Record<string, unknown>>(\n obj: T,\n predicate: (value: unknown, key: string) => boolean\n): Partial<T> {\n const result: Partial<T> = {};\n Object.keys(obj).forEach(key => {\n const typedKey = key as keyof T;\n if (predicate(obj[typedKey], key)) {\n result[typedKey] = obj[typedKey];\n }\n });\n return result;\n}\n\n/**\n * 条件排除属性\n * @param obj - 对象\n * @param predicate - 条件函数\n * @returns 不满足条件的属性组成的新对象\n */\nexport function omitBy<T extends Record<string, unknown>>(\n obj: T,\n predicate: (value: unknown, key: string) => boolean\n): Partial<T> {\n const result: Partial<T> = {};\n Object.keys(obj).forEach(key => {\n const typedKey = key as keyof T;\n if (!predicate(obj[typedKey], key)) {\n result[typedKey] = obj[typedKey];\n }\n });\n return result;\n}\n"]}
@@ -0,0 +1,138 @@
1
+ // src/core/array.ts
2
+ function unique(arr) {
3
+ return Array.from(new Set(arr));
4
+ }
5
+ function groupBy(arr, keyFn) {
6
+ const getKey = typeof keyFn === "string" ? (item) => item[keyFn] : keyFn;
7
+ return arr.reduce(
8
+ (acc, item) => {
9
+ const key = getKey(item);
10
+ if (!acc[key]) {
11
+ acc[key] = [];
12
+ }
13
+ acc[key].push(item);
14
+ return acc;
15
+ },
16
+ {}
17
+ );
18
+ }
19
+ function chunk(arr, size) {
20
+ const chunks = [];
21
+ for (let i = 0; i < arr.length; i += size) {
22
+ chunks.push(arr.slice(i, i + size));
23
+ }
24
+ return chunks;
25
+ }
26
+ function flatten(arr, depth = 1) {
27
+ return depth > 0 ? arr.reduce(
28
+ (acc, val) => acc.concat(Array.isArray(val) ? flatten(val, depth - 1) : val),
29
+ []
30
+ ) : arr;
31
+ }
32
+ function shuffle(arr) {
33
+ const result = [...arr];
34
+ for (let i = result.length - 1; i > 0; i--) {
35
+ const j = Math.floor(Math.random() * (i + 1));
36
+ [result[i], result[j]] = [result[j], result[i]];
37
+ }
38
+ return result;
39
+ }
40
+ function sample(arr, count = 1) {
41
+ if (arr.length === 0) {
42
+ throw new Error("Cannot sample from empty array");
43
+ }
44
+ if (count === 1) {
45
+ const shuffled2 = shuffle(arr);
46
+ return shuffled2[0];
47
+ }
48
+ if (count >= arr.length) return [...arr];
49
+ const shuffled = shuffle(arr);
50
+ return shuffled.slice(0, count);
51
+ }
52
+ function difference(arr1, arr2) {
53
+ const set2 = new Set(arr2);
54
+ return arr1.filter((item) => !set2.has(item));
55
+ }
56
+ function intersection(arr1, arr2) {
57
+ const set2 = new Set(arr2);
58
+ return arr1.filter((item) => set2.has(item));
59
+ }
60
+ function union(arr1, arr2) {
61
+ return unique([...arr1, ...arr2]);
62
+ }
63
+ function sortBy(arr, keyFn, order = "asc") {
64
+ const getKey = typeof keyFn === "string" ? (item) => item[keyFn] : keyFn;
65
+ const result = [...arr];
66
+ result.sort((a, b) => {
67
+ const keyA = getKey(a);
68
+ const keyB = getKey(b);
69
+ if (keyA < keyB) return order === "asc" ? -1 : 1;
70
+ if (keyA > keyB) return order === "asc" ? 1 : -1;
71
+ return 0;
72
+ });
73
+ return result;
74
+ }
75
+ function findIndexBy(arr, predicate) {
76
+ return arr.findIndex(predicate);
77
+ }
78
+ function partition(arr, predicate) {
79
+ const truthy = [];
80
+ const falsy = [];
81
+ arr.forEach((item) => {
82
+ if (predicate(item)) {
83
+ truthy.push(item);
84
+ } else {
85
+ falsy.push(item);
86
+ }
87
+ });
88
+ return [truthy, falsy];
89
+ }
90
+ function zip(...arrays) {
91
+ const maxLength = Math.max(...arrays.map((arr) => arr.length));
92
+ const result = [];
93
+ for (let i = 0; i < maxLength; i++) {
94
+ result.push(
95
+ arrays.map((arr) => arr[i])
96
+ );
97
+ }
98
+ return result;
99
+ }
100
+ function unzip(array) {
101
+ if (array.length === 0) return [];
102
+ const length = array[0].length;
103
+ const result = Array.from({ length }, () => []);
104
+ array.forEach((item) => {
105
+ item.forEach((val, index) => {
106
+ result[index].push(val);
107
+ });
108
+ });
109
+ return result;
110
+ }
111
+ function compact(arr) {
112
+ return arr.filter((item) => Boolean(item));
113
+ }
114
+ function take(arr, n) {
115
+ return arr.slice(0, n);
116
+ }
117
+ function drop(arr, n) {
118
+ return arr.slice(n);
119
+ }
120
+ function takeWhile(arr, predicate) {
121
+ const result = [];
122
+ for (const item of arr) {
123
+ if (!predicate(item)) break;
124
+ result.push(item);
125
+ }
126
+ return result;
127
+ }
128
+ function dropWhile(arr, predicate) {
129
+ let index = 0;
130
+ while (index < arr.length && predicate(arr[index])) {
131
+ index++;
132
+ }
133
+ return arr.slice(index);
134
+ }
135
+
136
+ export { chunk, compact, difference, drop, dropWhile, findIndexBy, flatten, groupBy, intersection, partition, sample, shuffle, sortBy, take, takeWhile, union, unique, unzip, zip };
137
+ //# sourceMappingURL=chunk-2FFSQ573.mjs.map
138
+ //# sourceMappingURL=chunk-2FFSQ573.mjs.map