sculp-js 1.13.0 → 1.13.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.
Files changed (127) hide show
  1. package/README.md +10 -11
  2. package/dist/cjs/_virtual/_commonjsHelpers.js +13 -0
  3. package/{lib → dist}/cjs/array.js +1 -1
  4. package/{lib → dist}/cjs/async.js +1 -1
  5. package/{lib/cjs/we-decode.js → dist/cjs/base64.js} +53 -44
  6. package/{lib → dist}/cjs/clipboard.js +1 -1
  7. package/{lib → dist}/cjs/cloneDeep.js +1 -1
  8. package/{lib → dist}/cjs/cookie.js +1 -1
  9. package/{lib → dist}/cjs/date.js +1 -1
  10. package/{lib → dist}/cjs/dom.js +1 -1
  11. package/{lib → dist}/cjs/download.js +1 -1
  12. package/dist/cjs/easing.js +75 -0
  13. package/{lib → dist}/cjs/file.js +1 -1
  14. package/{lib → dist}/cjs/func.js +1 -1
  15. package/{lib → dist}/cjs/index.js +10 -8
  16. package/{lib → dist}/cjs/math.js +1 -1
  17. package/dist/cjs/node_modules/bezier-easing/src/index.js +123 -0
  18. package/{lib → dist}/cjs/number.js +1 -1
  19. package/{lib → dist}/cjs/object.js +1 -1
  20. package/{lib → dist}/cjs/path.js +1 -1
  21. package/{lib → dist}/cjs/qs.js +1 -1
  22. package/{lib → dist}/cjs/random.js +1 -1
  23. package/{lib → dist}/cjs/string.js +1 -1
  24. package/{lib → dist}/cjs/tooltip.js +1 -1
  25. package/{lib → dist}/cjs/tree.js +36 -43
  26. package/{lib → dist}/cjs/type.js +1 -1
  27. package/{lib → dist}/cjs/unique.js +1 -1
  28. package/{lib → dist}/cjs/url.js +1 -1
  29. package/{lib → dist}/cjs/validator.js +1 -1
  30. package/{lib → dist}/cjs/variable.js +1 -1
  31. package/{lib → dist}/cjs/watermark.js +1 -1
  32. package/{lib/es → dist/esm}/array.js +1 -1
  33. package/{lib/es → dist/esm}/async.js +1 -1
  34. package/{lib/es/we-decode.js → dist/esm/base64.js} +52 -45
  35. package/{lib/es → dist/esm}/clipboard.js +1 -1
  36. package/{lib/es → dist/esm}/cloneDeep.js +1 -1
  37. package/{lib/es → dist/esm}/cookie.js +1 -1
  38. package/{lib/es → dist/esm}/date.js +1 -1
  39. package/{lib/es → dist/esm}/dom.js +1 -1
  40. package/{lib/es → dist/esm}/download.js +1 -1
  41. package/{lib/es → dist/esm}/easing.js +34 -2
  42. package/{lib/es → dist/esm}/file.js +1 -1
  43. package/{lib/es → dist/esm}/func.js +1 -1
  44. package/{lib/es → dist/esm}/index.js +3 -4
  45. package/{lib/es → dist/esm}/math.js +1 -1
  46. package/{lib/es → dist/esm}/number.js +1 -1
  47. package/{lib/es → dist/esm}/object.js +1 -1
  48. package/{lib/es → dist/esm}/path.js +1 -1
  49. package/{lib/es → dist/esm}/qs.js +1 -1
  50. package/{lib/es → dist/esm}/random.js +1 -1
  51. package/{lib/es → dist/esm}/string.js +1 -1
  52. package/{lib/es → dist/esm}/tooltip.js +1 -1
  53. package/{lib/es → dist/esm}/tree.js +36 -43
  54. package/{lib/es → dist/esm}/type.js +1 -1
  55. package/{lib/es → dist/esm}/unique.js +1 -1
  56. package/{lib/es → dist/esm}/url.js +1 -1
  57. package/{lib/es → dist/esm}/validator.js +1 -1
  58. package/{lib/es → dist/esm}/variable.js +1 -1
  59. package/{lib/es → dist/esm}/watermark.js +1 -1
  60. package/dist/types/array.d.ts +50 -0
  61. package/dist/types/array.d.ts.map +1 -0
  62. package/dist/types/async.d.ts +37 -0
  63. package/dist/types/async.d.ts.map +1 -0
  64. package/dist/types/base64.d.ts +25 -0
  65. package/dist/types/base64.d.ts.map +1 -0
  66. package/dist/types/clipboard.d.ts +20 -0
  67. package/dist/types/clipboard.d.ts.map +1 -0
  68. package/dist/types/cloneDeep.d.ts +12 -0
  69. package/dist/types/cloneDeep.d.ts.map +1 -0
  70. package/dist/types/cookie.d.ts +19 -0
  71. package/dist/types/cookie.d.ts.map +1 -0
  72. package/dist/types/core-index.d.ts +17 -0
  73. package/dist/types/core-index.d.ts.map +1 -0
  74. package/dist/types/date.d.ts +74 -0
  75. package/dist/types/date.d.ts.map +1 -0
  76. package/dist/types/dom.d.ts +74 -0
  77. package/dist/types/dom.d.ts.map +1 -0
  78. package/dist/types/download.d.ts +47 -0
  79. package/dist/types/download.d.ts.map +1 -0
  80. package/dist/types/easing.d.ts +32 -0
  81. package/dist/types/easing.d.ts.map +1 -0
  82. package/dist/types/file.d.ts +44 -0
  83. package/dist/types/file.d.ts.map +1 -0
  84. package/dist/types/func.d.ts +50 -0
  85. package/dist/types/func.d.ts.map +1 -0
  86. package/dist/types/index.d.ts +28 -0
  87. package/dist/types/index.d.ts.map +1 -0
  88. package/dist/types/index.js +3258 -0
  89. package/dist/types/math.d.ts +36 -0
  90. package/dist/types/math.d.ts.map +1 -0
  91. package/dist/types/number.d.ts +49 -0
  92. package/dist/types/number.d.ts.map +1 -0
  93. package/dist/types/object.d.ts +70 -0
  94. package/dist/types/object.d.ts.map +1 -0
  95. package/dist/types/path.d.ts +14 -0
  96. package/dist/types/path.d.ts.map +1 -0
  97. package/dist/types/qs.d.ts +22 -0
  98. package/dist/types/qs.d.ts.map +1 -0
  99. package/dist/types/random.d.ts +27 -0
  100. package/dist/types/random.d.ts.map +1 -0
  101. package/dist/types/string.d.ts +67 -0
  102. package/dist/types/string.d.ts.map +1 -0
  103. package/dist/types/tooltip.d.ts +36 -0
  104. package/dist/types/tooltip.d.ts.map +1 -0
  105. package/dist/types/tree.d.ts +98 -0
  106. package/dist/types/tree.d.ts.map +1 -0
  107. package/dist/types/type.d.ts +124 -0
  108. package/dist/types/type.d.ts.map +1 -0
  109. package/dist/types/unique.d.ts +21 -0
  110. package/dist/types/unique.d.ts.map +1 -0
  111. package/dist/types/url.d.ts +46 -0
  112. package/dist/types/url.d.ts.map +1 -0
  113. package/dist/types/validator.d.ts +67 -0
  114. package/dist/types/validator.d.ts.map +1 -0
  115. package/dist/types/variable.d.ts +71 -0
  116. package/dist/types/variable.d.ts.map +1 -0
  117. package/dist/types/watermark.d.ts +19 -0
  118. package/dist/types/watermark.d.ts.map +1 -0
  119. package/dist/umd/index.min.js +6 -0
  120. package/package.json +234 -17
  121. package/lib/cjs/base64.js +0 -62
  122. package/lib/cjs/easing.js +0 -40
  123. package/lib/cjs/isEqual.js +0 -133
  124. package/lib/es/base64.js +0 -59
  125. package/lib/es/isEqual.js +0 -131
  126. package/lib/index.d.ts +0 -1211
  127. package/lib/umd/index.js +0 -6
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -53,19 +53,15 @@ function forEachDeep(tree, iterator, options = {
53
53
  else if (re === true) {
54
54
  continue;
55
55
  }
56
- // @ts-ignore
57
56
  if (item && Array.isArray(item[childField])) {
58
- // @ts-ignore
59
57
  walk(item[childField], item, level + 1);
60
58
  }
61
59
  }
62
60
  }
63
61
  if (breadthFirst) {
64
62
  // Process queue
65
- while (!isBreak) {
63
+ while (queue.length > 0 && !isBreak) {
66
64
  const current = queue.shift();
67
- // iterate(info);
68
- // @ts-ignore
69
65
  const { item, index, array, tree, parent, level } = current;
70
66
  const re = iterator(item, index, array, tree, parent, level);
71
67
  if (re === false) {
@@ -75,9 +71,7 @@ function forEachDeep(tree, iterator, options = {
75
71
  else if (re === true) {
76
72
  continue;
77
73
  }
78
- // @ts-ignore
79
74
  if (item && Array.isArray(item[childField])) {
80
- // @ts-ignore
81
75
  walk(item[childField], item, level + 1);
82
76
  }
83
77
  }
@@ -103,19 +97,16 @@ function forEachDeep(tree, iterator, options = {
103
97
  else if (re === true) {
104
98
  continue;
105
99
  }
106
- // @ts-ignore
107
100
  if (item && Array.isArray(item[childField])) {
108
- // @ts-ignore
109
101
  walk(item[childField], item, level + 1);
110
102
  }
111
103
  }
112
104
  }
113
105
  if (breadthFirst) {
114
- while (!isBreak) {
106
+ while (queue.length > 0 && !isBreak) {
115
107
  const current = queue.shift();
116
108
  if (!current)
117
109
  break;
118
- // @ts-ignore
119
110
  const { item, index, array, tree, parent, level } = current;
120
111
  const re = iterator(item, index, array, tree, parent, level);
121
112
  if (re === false) {
@@ -125,9 +116,7 @@ function forEachDeep(tree, iterator, options = {
125
116
  else if (re === true) {
126
117
  continue;
127
118
  }
128
- // @ts-ignore
129
119
  if (item && Array.isArray(item[childField])) {
130
- // @ts-ignore
131
120
  walk(item[childField], item, level + 1);
132
121
  }
133
122
  }
@@ -144,20 +133,27 @@ function forEachDeep(tree, iterator, options = {
144
133
  * 可遍历任何带有 length 属性和数字键的类数组对象
145
134
  * @param {ArrayLike<V>} tree 树形数据
146
135
  * @param {Function} iterator 迭代函数, 返回值为true时continue, 返回值为false时break
147
- * @param {string} children 定制子元素的key
148
- * @param {boolean} isReverse 是否反向遍历
136
+ * @param {options} options 支持定制子元素名称、反向遍历,默认{
137
+ childField: 'children',
138
+ reverse: false,
139
+ }
149
140
  * @returns {any[]} 新的一棵树
150
141
  */
151
- function mapDeep(tree, iterator, children = 'children', isReverse = false) {
142
+ function mapDeep(tree, iterator, options = {
143
+ childField: 'children',
144
+ reverse: false
145
+ }) {
146
+ const { childField = 'children', reverse = false } = isObject(options) ? options : {};
152
147
  let isBreak = false;
153
148
  const newTree = [];
154
149
  const walk = (arr, parent, newTree, level = 0) => {
155
- if (isReverse) {
150
+ if (reverse) {
156
151
  for (let i = arr.length - 1; i >= 0; i--) {
157
152
  if (isBreak) {
158
153
  break;
159
154
  }
160
- const re = iterator(arr[i], i, arr, tree, parent, level);
155
+ const item = arr[i];
156
+ const re = iterator(item, i, arr, tree, parent, level);
161
157
  if (re === false) {
162
158
  isBreak = true;
163
159
  break;
@@ -165,16 +161,14 @@ function mapDeep(tree, iterator, children = 'children', isReverse = false) {
165
161
  else if (re === true) {
166
162
  continue;
167
163
  }
168
- newTree.push(objectOmit(re, [children]));
169
- // @ts-ignore
170
- if (arr[i] && Array.isArray(arr[i][children])) {
171
- newTree[newTree.length - 1][children] = [];
172
- // @ts-ignore
173
- walk(arr[i][children], arr[i], newTree[newTree.length - 1][children], level + 1);
164
+ newTree.push(objectOmit(re, [childField]));
165
+ if (item && Array.isArray(item[childField])) {
166
+ newTree[newTree.length - 1][childField] = [];
167
+ walk(item[childField], item, newTree[newTree.length - 1][childField], level + 1);
174
168
  }
175
169
  else {
176
170
  // children非有效数组时,移除该属性字段
177
- delete re[children];
171
+ delete re[childField];
178
172
  }
179
173
  }
180
174
  }
@@ -183,7 +177,8 @@ function mapDeep(tree, iterator, children = 'children', isReverse = false) {
183
177
  if (isBreak) {
184
178
  break;
185
179
  }
186
- const re = iterator(arr[i], i, arr, tree, parent, level);
180
+ const item = arr[i];
181
+ const re = iterator(item, i, arr, tree, parent, level);
187
182
  if (re === false) {
188
183
  isBreak = true;
189
184
  break;
@@ -191,16 +186,14 @@ function mapDeep(tree, iterator, children = 'children', isReverse = false) {
191
186
  else if (re === true) {
192
187
  continue;
193
188
  }
194
- newTree.push(objectOmit(re, [children]));
195
- // @ts-ignore
196
- if (arr[i] && Array.isArray(arr[i][children])) {
197
- newTree[newTree.length - 1][children] = [];
198
- // @ts-ignore
199
- walk(arr[i][children], arr[i], newTree[newTree.length - 1][children], level + 1);
189
+ newTree.push(objectOmit(re, [childField]));
190
+ if (item && Array.isArray(item[childField])) {
191
+ newTree[newTree.length - 1][childField] = [];
192
+ walk(item[childField], item, newTree[newTree.length - 1][childField], level + 1);
200
193
  }
201
194
  else {
202
195
  // children非有效数组时,移除该属性字段
203
- delete re[children];
196
+ delete re[childField];
204
197
  }
205
198
  }
206
199
  }
@@ -214,30 +207,30 @@ function mapDeep(tree, iterator, children = 'children', isReverse = false) {
214
207
  * 在树中找到 id 为某个值的节点,并返回上游的所有父级节点
215
208
  *
216
209
  * @param {ArrayLike<T>} tree - 树形数据
217
- * @param {IdLike} nodeId - 元素ID
218
- * @param {ITreeConf} config - 迭代配置项
219
- * @returns {[IdLike[], ITreeItem<V>[]]} - 由parentId...childId, parentObject-childObject组成的二维数组
210
+ * @param {number | string} nodeId - 目标元素ID
211
+ * @param {ITreeConf} options - 迭代配置项, 默认:{ children = 'children', id = 'id' }
212
+ * @returns {[(number | string)[], V[]]} - 由parentId...childId, parentObject-childObject组成的二维数组
220
213
  */
221
- function searchTreeById(tree, nodeId, config) {
222
- const { children = 'children', id = 'id' } = config || {};
214
+ function searchTreeById(tree, nodeId, options = { childField: 'children', keyField: 'id' }) {
215
+ const { childField = 'children', keyField = 'id' } = isObject(options) ? options : {};
223
216
  const toFlatArray = (tree, parentId, parent) => {
224
217
  return tree.reduce((t, _) => {
225
- const child = _[children];
218
+ const child = _[childField];
226
219
  return [
227
220
  ...t,
228
221
  parentId ? { ..._, parentId, parent } : _,
229
- ...(child && child.length ? toFlatArray(child, _[id], _) : [])
222
+ ...(child && child.length ? toFlatArray(child, _[keyField], _) : [])
230
223
  ];
231
224
  }, []);
232
225
  };
233
226
  const getIds = (flatArray) => {
234
- let child = flatArray.find(_ => _[id] === nodeId);
227
+ let child = flatArray.find(_ => _[keyField] === nodeId);
235
228
  const { parent, parentId, ...other } = child;
236
229
  let ids = [nodeId], nodes = [other];
237
230
  while (child && child.parentId) {
238
231
  ids = [child.parentId, ...ids];
239
232
  nodes = [child.parent, ...nodes];
240
- child = flatArray.find(_ => _[id] === child.parentId); // eslint-disable-line
233
+ child = flatArray.find(_ => _[keyField] === child.parentId); // eslint-disable-line
241
234
  }
242
235
  return [ids, nodes];
243
236
  };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -0,0 +1,50 @@
1
+ import { AnyArray } from './type';
2
+ /**
3
+ * 遍历数组,返回 false 中断遍历(支持continue和break操作)
4
+ *
5
+ * @param {ArrayLike<V>} array
6
+ * @param {(val: V, idx: number) => any} iterator 迭代函数, 返回值为true时continue, 返回值为false时break
7
+ * @param {boolean} reverse 是否倒序
8
+ * @returns {*}
9
+ */
10
+ export declare function arrayEach<V>(array: ArrayLike<V>, iterator: (val: V, idx: number, arr: ArrayLike<V>) => boolean | void, reverse?: boolean): void;
11
+ /**
12
+ * 异步遍历数组,返回 false 中断遍历
13
+ * @param {ArrayLike<V>} array 数组
14
+ * @param {(val: V, idx: number) => Promise<any>} iterator 支持Promise类型的回调函数
15
+ * @param {boolean} reverse 是否反向遍历
16
+ * @example
17
+ * 使用范例如下:
18
+ * const start = async () => {
19
+ * await arrayEachAsync(result, async (item) => {
20
+ * await request(item);
21
+ * count++;
22
+ * })
23
+ * console.log('发送次数', count);
24
+ * }
25
+
26
+ * for await...of 使用范例如下
27
+ * const loadImages = async (images) => {
28
+ * for await (const item of images) {
29
+ * await request(item);
30
+ * count++;
31
+ * }
32
+ * }
33
+ */
34
+ export declare function arrayEachAsync<V>(array: ArrayLike<V>, iterator: (val: V, idx: number) => Promise<any> | any, reverse?: boolean): Promise<void>;
35
+ /**
36
+ * 插入到目标位置之前
37
+ * @param {AnyArray} array
38
+ * @param {number} start
39
+ * @param {number} to
40
+ * @returns {*}
41
+ */
42
+ export declare function arrayInsertBefore(array: AnyArray, start: number, to: number): void;
43
+ /**
44
+ * 数组删除指定项目
45
+ * @param {V[]} array
46
+ * @param {(val: V, idx: number) => boolean} expect
47
+ * @returns {V[]}
48
+ */
49
+ export declare function arrayRemove<V>(array: V[], expect: (val: V, idx: number) => boolean): V[];
50
+ //# sourceMappingURL=array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAqB,MAAM,QAAQ,CAAC;AAErD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,IAAI,EACpE,OAAO,UAAQ,GACd,IAAI,CAgBN;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,EACrD,OAAO,UAAQ,GACd,OAAO,CAAC,IAAI,CAAC,CAUf;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAOlF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,GAAG,CAAC,EAAE,CAexF"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * 等待一段时间
3
+ * @param {number} timeout 等待时间,单位毫秒
4
+ * @returns {Promise<void>}
5
+ */
6
+ export declare function wait(timeout?: number): Promise<void>;
7
+ /**
8
+ * 异步遍历
9
+ * @ref https://github.com/Kevnz/async-tools/blob/master/src/mapper.js
10
+ * @ref https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/@@iterator
11
+ * @param {Array<T>} list
12
+ * @param {(val: T, idx: number, list: ArrayLike<T>) => Promise<R>} mapper
13
+ * @param {number} concurrency 并发数量,默认无限
14
+ * @returns {Promise<R[]>}
15
+ */
16
+ export declare function asyncMap<T, R>(list: Array<T>, mapper: (val: T, idx: number, list: Array<T>) => Promise<R>, concurrency?: number): Promise<R[]>;
17
+ /**
18
+ * Execute a promise safely
19
+ *
20
+ * @param { Promise } promise
21
+ * @param { Object= } errorExt - Additional Information you can pass safeAwait the err object
22
+ * @return { Promise }
23
+ * @example
24
+ * async function asyncTaskWithCb(cb) {
25
+ let err, user, savedTask, notification;
26
+
27
+ [ err, user ] = await safeAwait(UserModel.findById(1));
28
+ if(!user) return cb('No user found');
29
+
30
+ [ err, savedTask ] = await safeAwait(TaskModel({userId: user.id, name: 'Demo Task'}));
31
+ if(err) return cb('Error occurred while saving task')
32
+
33
+ cb(null, savedTask);
34
+ }
35
+ */
36
+ export declare function safeAwait<T, U = Error>(promise: Promise<T>, errorExt?: object): Promise<[U, undefined] | [null, T]>;
37
+ //# sourceMappingURL=async.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/async.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,SAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAC3B,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAC3D,WAAW,SAAW,GACrB,OAAO,CAAC,CAAC,EAAE,CAAC,CAsCd;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAWnH"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * 字符串编码成Base64, 平替浏览器的btoa, 不包含中文的处理 (适用于任何环境,包括小程序)
3
+ * @param {string} string
4
+ * @returns {string}
5
+ */
6
+ export declare function weBtoa(string: string): string;
7
+ /**
8
+ * Base64解码为原始字符串,平替浏览器的atob, 不包含中文的处理(适用于任何环境,包括小程序)
9
+ * @param {string} string
10
+ * @returns {string}
11
+ */
12
+ export declare function weAtob(string: string): string;
13
+ /**
14
+ * 将base64编码的字符串转换为原始字符串,包括对中文内容的处理(高性能,且支持Web、Node、小程序等任意平台)
15
+ * @param base64 base64编码的字符串
16
+ * @returns 原始字符串,包括中文内容
17
+ */
18
+ export declare function b64decode(base64: string): string;
19
+ /**
20
+ * 将原始字符串,包括中文内容,转换为base64编码的字符串(高性能,且支持Web、Node、小程序等任意平台)
21
+ * @param rawStr 原始字符串,包括中文内容
22
+ * @returns base64编码的字符串
23
+ */
24
+ export declare function b64encode(rawStr: string): string;
25
+ //# sourceMappingURL=base64.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../src/base64.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAwB7C;AACD;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAyB7C;AAcD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAYhD;AACD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAahD"}
@@ -0,0 +1,20 @@
1
+ import { AsyncCallback } from './type';
2
+ type CopyTextOptions = AsyncCallback & {
3
+ container?: HTMLElement;
4
+ };
5
+ /**
6
+ * 复制文本,优先使用navigator.clipboard,仅在安全上下文(HTTPS/localhost)下生效,若不支持则回退使用execCommand方式
7
+ * @param {string} text
8
+ * @param {CopyTextOptions} options 可选参数:成功回调successCallback、失败回调failCallback、容器元素container
9
+ * (默认document.body, 当不支持clipboard时必须传复制按钮元素,包裹模拟选择操作的临时元素,
10
+ * 解决脱离文档流的元素无法复制的问题,如Modal内复制操作)
11
+ */
12
+ export declare function copyText(text: string, options?: CopyTextOptions): void;
13
+ /**
14
+ * 使用execCommand方式复制文本
15
+ * @param text
16
+ * @param options
17
+ */
18
+ export declare function fallbackCopyText(text: string, options?: CopyTextOptions): void;
19
+ export {};
20
+ //# sourceMappingURL=clipboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../src/clipboard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAyB,MAAM,QAAQ,CAAC;AAE9D,KAAK,eAAe,GAAG,aAAa,GAAG;IAAE,SAAS,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAEnE;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,CAiBtE;AACD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,CAyB9E"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 深拷贝堪称完全体 即:任何类型的数据都会被深拷贝
3
+ *
4
+ * 包含对null、原始值、对象循环引用的处理
5
+ *
6
+ * 对Map、Set、ArrayBuffer、Date、RegExp、Array、Object及原型链属性方法执行深拷贝
7
+ * @param {T} source
8
+ * @param {WeakMap} map
9
+ * @returns {T}
10
+ */
11
+ export declare function cloneDeep<T>(source: T, map?: WeakMap<any, any>): T;
12
+ //# sourceMappingURL=cloneDeep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloneDeep.d.ts","sourceRoot":"","sources":["../../src/cloneDeep.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,oBAA0B,GAAG,CAAC,CA+GxE"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * 获取cookie
3
+ * @param {string} name
4
+ * @returns {string}
5
+ */
6
+ export declare function cookieGet(name: string): string;
7
+ /**
8
+ * 设置 cookie
9
+ * @param {string} name
10
+ * @param {string} value
11
+ * @param {number | Date} [maxAge]
12
+ */
13
+ export declare function cookieSet(name: string, value: string, maxAge?: number | Date): void;
14
+ /**
15
+ * 删除单个 cookie
16
+ * @param name cookie 名称
17
+ */
18
+ export declare const cookieDel: (name: string) => void;
19
+ //# sourceMappingURL=cookie.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../src/cookie.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAe9C;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAsBnF;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,SAAU,MAAM,KAAG,IAA+B,CAAC"}
@@ -0,0 +1,17 @@
1
+ export * from './array';
2
+ export * from './date';
3
+ export * from './object';
4
+ export * from './path';
5
+ export * from './string';
6
+ export * from './type';
7
+ export * from './async';
8
+ export * from './func';
9
+ export * from './random';
10
+ export * from './number';
11
+ export * from './unique';
12
+ export * from './tree';
13
+ export * from './math';
14
+ export * from './base64';
15
+ export * from './validator';
16
+ export * from './variable';
17
+ //# sourceMappingURL=core-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-index.d.ts","sourceRoot":"","sources":["../../src/core-index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,74 @@
1
+ export declare const isValidDate: (any: unknown) => any is Date;
2
+ export interface DateObj {
3
+ [propName: string]: string;
4
+ }
5
+ export type DateValue = number | string | Date;
6
+ /**
7
+ * 解析为Date对象
8
+ * @param {DateValue} value - 可以是数值、字符串或 Date 对象
9
+ * @returns {Date} - 转换后的目标Date
10
+ */
11
+ export declare function dateParse(value: DateValue): Date;
12
+ /**
13
+ * 格式化为日期对象(带自定义格式化模板)
14
+ * @param {DateValue} value 可以是数值、字符串或 Date 对象
15
+ * @param {string} [format] 模板,默认是 YYYY-MM-DD HH:mm:ss,模板字符:
16
+ * - YYYY:年
17
+ * - yyyy: 年
18
+ * - MM:月
19
+ * - DD:日
20
+ * - dd: 日
21
+ * - HH:时(24 小时制)
22
+ * - hh:时(12 小时制)
23
+ * - mm:分
24
+ * - ss:秒
25
+ * - SSS:毫秒
26
+ * @returns {string}
27
+ */
28
+ /**
29
+ * 将日期转换为一天的开始时间,即0点0分0秒0毫秒
30
+ * @param {DateValue} value
31
+ * @returns {Date}
32
+ */
33
+ export declare function dateToStart(value: DateValue): Date;
34
+ /**
35
+ * 将日期转换为一天的结束时间,即23点59分59秒999毫秒
36
+ * @param {DateValue} value
37
+ * @returns {Date}
38
+ */
39
+ export declare function dateToEnd(value: DateValue): Date;
40
+ /**
41
+ * 格式化为日期对象(带自定义格式化模板)
42
+ * @param {Date} value - 可以是数值、字符串或 Date 对象
43
+ * @param {string} [format] - 模板,默认是 YYYY-MM-DD HH:mm:ss,模板字符:
44
+ * - YYYY:年
45
+ * - yyyy: 年
46
+ * - MM:月
47
+ * - DD:日
48
+ * - dd: 日
49
+ * - HH:时(24 小时制)
50
+ * - mm:分
51
+ * - ss:秒
52
+ * - SSS:毫秒
53
+ * - ww: 周
54
+ * @returns {string} 格式化后的日期字符串
55
+ */
56
+ export declare function formatDate(value: DateValue, format?: string): string;
57
+ /**
58
+ * 计算向前或向后N天的具体日期
59
+ * @param {DateValue} originDate - 参考日期
60
+ * @param {number} n - 正数:向后推算;负数:向前推算
61
+ * @param {string} sep - 日期格式的分隔符
62
+ * @returns {string} 计算后的目标日期
63
+ */
64
+ export declare function calculateDate(originDate: DateValue, n: number, sep?: string): string;
65
+ /**
66
+ * 计算向前或向后N天的具体日期时间
67
+ * @param {DateValue} originDateTime - 参考日期时间
68
+ * @param {number} n - 正数:向后推算;负数:向前推算
69
+ * @param {string} dateSep - 日期分隔符
70
+ * @param {string} timeSep - 时间分隔符
71
+ * @returns {string} 转换后的目标日期时间
72
+ */
73
+ export declare function calculateDateTime(originDateTime: DateValue, n: number, dateSep?: string, timeSep?: string): string;
74
+ //# sourceMappingURL=date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/date.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,QAAS,OAAO,gBAAsD,CAAC;AAE/F,MAAM,WAAW,OAAO;IACtB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAqC/C;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAmBhD;AAED;;;;;;;;;;;;;;;GAeG;AA2BH;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAGlD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAIhD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,SAAwB,GAAG,MAAM,CA0BnF;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,GAAE,MAAY,GAAG,MAAM,CAazF;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,SAAS,EACzB,CAAC,EAAE,MAAM,EACT,OAAO,GAAE,MAAY,EACrB,OAAO,GAAE,MAAY,GACpB,MAAM,CA2BR"}
@@ -0,0 +1,74 @@
1
+ import { EasingName } from './easing';
2
+ export interface Style {
3
+ [propName: string]: string | number;
4
+ }
5
+ /**
6
+ * 判断元素是否包含某个样式名
7
+ * @param {HTMLElement} el
8
+ * @param {string} className
9
+ * @returns {boolean}
10
+ */
11
+ export declare function hasClass(el: HTMLElement, className: string): boolean;
12
+ /**
13
+ * 给元素增加样式名
14
+ * @param {HTMLElement} el
15
+ * @param {string} classNames
16
+ */
17
+ export declare function addClass(el: HTMLElement, classNames: string): void;
18
+ /**
19
+ * 给元素移除样式名
20
+ * @param {HTMLElement} el
21
+ * @param {string} classNames
22
+ */
23
+ export declare function removeClass(el: HTMLElement, classNames: string): void;
24
+ export interface SetStyle {
25
+ (el: HTMLElement, key: string, val: string): void;
26
+ (el: HTMLElement, style: Style): void;
27
+ }
28
+ /**
29
+ * 设置元素样式
30
+ * @param {HTMLElement} el
31
+ * @param {string | Style} key
32
+ * @param {string} val
33
+ */
34
+ export declare const setStyle: SetStyle;
35
+ /**
36
+ * 获取元素样式
37
+ * @param {HTMLElement} el 元素
38
+ * @param {string} key
39
+ * @returns {string}
40
+ */
41
+ export declare function getStyle(el: HTMLElement, key: string): string;
42
+ type ScrollElement = HTMLElement | Document | Window;
43
+ export interface SmoothScrollOptions {
44
+ el: ScrollElement;
45
+ to: number;
46
+ duration: number;
47
+ easing: EasingName;
48
+ }
49
+ export declare function smoothScroll(options?: Partial<SmoothScrollOptions>): Promise<void>;
50
+ /**
51
+ * 获取元素样式属性的计算值
52
+ * @param {HTMLElement} el
53
+ * @param {string} property
54
+ * @param {boolean} reNumber
55
+ * @returns {string|number}
56
+ */
57
+ export declare function getComputedCssVal(el: HTMLElement, property: string, reNumber?: boolean): string | number;
58
+ /**
59
+ * 字符串的像素宽度
60
+ * @param {string} str 目标字符串
61
+ * @param {number} fontSize 字符串字体大小
62
+ * @param {boolean} isRemove 计算后是否移除创建的dom元素
63
+ * @returns {*}
64
+ */
65
+ export declare function getStrWidthPx(str: string, fontSize?: number, isRemove?: boolean): number;
66
+ /**
67
+ * Programmatically select the text of a HTML element
68
+ *
69
+ * @param {HTMLElement} element The element whose text you wish to select
70
+ * @returns
71
+ */
72
+ export declare function select(element: HTMLElement): any;
73
+ export {};
74
+ //# sourceMappingURL=dom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/dom.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,UAAU,EAAE,MAAM,UAAU,CAAC;AAKxD,MAAM,WAAW,KAAK;IACpB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CACrC;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAGpE;AAQD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAElE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAErE;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAClD,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACvC;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,QAQtB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,KAAK,aAAa,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AACrD,MAAM,WAAW,mBAAmB;IAElC,EAAE,EAAE,aAAa,CAAC;IAElB,EAAE,EAAE,MAAM,CAAC;IAEX,QAAQ,EAAE,MAAM,CAAC;IAEjB,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAoDlF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,OAAc,GAAG,MAAM,GAAG,MAAM,CAG9G;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAW,EAAE,QAAQ,GAAE,OAAc,GAAG,MAAM,CA2BlG;AACD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,WAAW,OAyC1C"}