foreslash 0.2.4 → 0.3.1
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/CHANGELOG.md +31 -1
- package/LICENSE +127 -9
- package/lib/index.cmn.cjs +285 -9
- package/lib/index.d.ts +260 -10
- package/lib/index.mjs +278 -10
- package/lib/index.umd.js +2135 -1859
- package/package.json +7 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,45 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
## Version 0.
|
|
3
|
+
## Version 0.3.1 - 2025-08-14
|
|
4
|
+
|
|
5
|
+
Unstable version
|
|
6
|
+
|
|
7
|
+
- Feat 🥥 Functions added: `indent` and so forth
|
|
8
|
+
- Use GitHub Actions to automate the npm publish/github release process
|
|
9
|
+
- Other fixes and improvements
|
|
10
|
+
|
|
11
|
+
不稳定版本
|
|
12
|
+
|
|
13
|
+
- 功能 🥥 添加函数: `indent` 等
|
|
14
|
+
- 使用 GitHub Actions 实现自动化 npm 发版/github release 流程
|
|
15
|
+
- 其他修复与优化
|
|
16
|
+
|
|
17
|
+
## Version 0.3.0 - 2025-07-01
|
|
18
|
+
|
|
19
|
+
Unstable version
|
|
20
|
+
|
|
21
|
+
- Feat 🥥 Functions added: `capitalize` `deepMerge` `isBlob` and so forth
|
|
22
|
+
- Feat 🥥 Function change: `deepClone` now support `Blob` and `File`
|
|
23
|
+
- Other fixes and improvements
|
|
24
|
+
|
|
25
|
+
不稳定版本
|
|
26
|
+
|
|
27
|
+
- 功能 🥥 添加函数: `capitalize` `deepMerge` `isBlob` 等
|
|
28
|
+
- 功能 🥥 变更函数: `deepClone` 现在支持 `Blob` 和 `File`
|
|
29
|
+
- 其他修复与优化
|
|
30
|
+
|
|
31
|
+
## Version 0.2.4 - 2025-05-29
|
|
4
32
|
|
|
5
33
|
Unstable version
|
|
6
34
|
|
|
7
35
|
- Feat 🥥 Functions added: `retry` `parallel`
|
|
36
|
+
- Change 🥟 Dependencies change: upgrade devDependencies `rollup` `@rollup/plugin-typescript` `rollup-plugin-dts` `vitepress`
|
|
8
37
|
- Other fixes and improvements
|
|
9
38
|
|
|
10
39
|
不稳定版本
|
|
11
40
|
|
|
12
41
|
- 功能 🥥 添加函数: `retry` `parallel`
|
|
42
|
+
- 变更 🥟 依赖变更: 升级开发依赖 `rollup` `@rollup/plugin-typescript` `rollup-plugin-dts` `vitepress`
|
|
13
43
|
- 其他修复与优化
|
|
14
44
|
|
|
15
45
|
## Version 0.2.3 - 2025-03-28
|
package/LICENSE
CHANGED
|
@@ -1,9 +1,127 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
木兰宽松许可证, 第2版
|
|
2
|
+
|
|
3
|
+
木兰宽松许可证, 第2版
|
|
4
|
+
2020年1月 http://license.coscl.org.cn/MulanPSL2
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
|
|
8
|
+
|
|
9
|
+
0. 定义
|
|
10
|
+
|
|
11
|
+
“软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
|
|
12
|
+
|
|
13
|
+
“贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
|
|
14
|
+
|
|
15
|
+
“贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
|
|
16
|
+
|
|
17
|
+
“法人实体”是指提交贡献的机构及其“关联实体”。
|
|
18
|
+
|
|
19
|
+
“关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
|
|
20
|
+
|
|
21
|
+
1. 授予版权许可
|
|
22
|
+
|
|
23
|
+
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
|
|
24
|
+
|
|
25
|
+
2. 授予专利许可
|
|
26
|
+
|
|
27
|
+
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
|
|
28
|
+
|
|
29
|
+
3. 无商标许可
|
|
30
|
+
|
|
31
|
+
“本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。
|
|
32
|
+
|
|
33
|
+
4. 分发限制
|
|
34
|
+
|
|
35
|
+
您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
|
|
36
|
+
|
|
37
|
+
5. 免责声明与责任限制
|
|
38
|
+
|
|
39
|
+
“软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
|
|
40
|
+
|
|
41
|
+
6. 语言
|
|
42
|
+
“本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
|
|
43
|
+
|
|
44
|
+
条款结束
|
|
45
|
+
|
|
46
|
+
如何将木兰宽松许可证,第2版,应用到您的软件
|
|
47
|
+
|
|
48
|
+
如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
|
|
49
|
+
|
|
50
|
+
1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
|
|
51
|
+
|
|
52
|
+
2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
|
|
53
|
+
|
|
54
|
+
3, 请将如下声明文本放入每个源文件的头部注释中。
|
|
55
|
+
|
|
56
|
+
Copyright (c) 2024-2025 moushu
|
|
57
|
+
foreslash is licensed under Mulan PSL v2.
|
|
58
|
+
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
59
|
+
You may obtain a copy of Mulan PSL v2 at:
|
|
60
|
+
http://license.coscl.org.cn/MulanPSL2
|
|
61
|
+
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
62
|
+
See the Mulan PSL v2 for more details.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
Mulan Permissive Software License,Version 2
|
|
66
|
+
|
|
67
|
+
Mulan Permissive Software License,Version 2 (Mulan PSL v2)
|
|
68
|
+
January 2020 http://license.coscl.org.cn/MulanPSL2
|
|
69
|
+
|
|
70
|
+
Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
|
|
71
|
+
|
|
72
|
+
0. Definition
|
|
73
|
+
|
|
74
|
+
Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
|
|
75
|
+
|
|
76
|
+
Contribution means the copyrightable work licensed by a particular Contributor under this License.
|
|
77
|
+
|
|
78
|
+
Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
|
|
79
|
+
|
|
80
|
+
Legal Entity means the entity making a Contribution and all its Affiliates.
|
|
81
|
+
|
|
82
|
+
Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
|
|
83
|
+
|
|
84
|
+
1. Grant of Copyright License
|
|
85
|
+
|
|
86
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
|
|
87
|
+
|
|
88
|
+
2. Grant of Patent License
|
|
89
|
+
|
|
90
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
|
|
91
|
+
|
|
92
|
+
3. No Trademark License
|
|
93
|
+
|
|
94
|
+
No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4.
|
|
95
|
+
|
|
96
|
+
4. Distribution Restriction
|
|
97
|
+
|
|
98
|
+
You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
|
|
99
|
+
|
|
100
|
+
5. Disclaimer of Warranty and Limitation of Liability
|
|
101
|
+
|
|
102
|
+
THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
103
|
+
|
|
104
|
+
6. Language
|
|
105
|
+
|
|
106
|
+
THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
|
|
107
|
+
|
|
108
|
+
END OF THE TERMS AND CONDITIONS
|
|
109
|
+
|
|
110
|
+
How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software
|
|
111
|
+
|
|
112
|
+
To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
|
|
113
|
+
|
|
114
|
+
i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
|
|
115
|
+
|
|
116
|
+
ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package;
|
|
117
|
+
|
|
118
|
+
iii Attach the statement to the appropriate annotated syntax at the beginning of each source file.
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
Copyright (c) 2024-2025 moushu
|
|
122
|
+
foreslash is licensed under Mulan PSL v2.
|
|
123
|
+
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
124
|
+
You may obtain a copy of Mulan PSL v2 at:
|
|
125
|
+
http://license.coscl.org.cn/MulanPSL2
|
|
126
|
+
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
127
|
+
See the Mulan PSL v2 for more details.
|
package/lib/index.cmn.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Copyright (c) 2024 moushu
|
|
2
|
+
Copyright (c) 2024-2025 moushu
|
|
3
3
|
foreslash is licensed under Mulan PSL v2.
|
|
4
4
|
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
5
5
|
You may obtain a copy of Mulan PSL v2 at:
|
|
@@ -116,8 +116,8 @@ function getGlobalThis() {
|
|
|
116
116
|
return Function('return this')();
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
const global$
|
|
120
|
-
const ArrayBuffer$1 = global$
|
|
119
|
+
const global$8 = getGlobalThis();
|
|
120
|
+
const ArrayBuffer$1 = global$8.ArrayBuffer;
|
|
121
121
|
function isArrayBuffer(val) {
|
|
122
122
|
return !!ArrayBuffer$1 && val instanceof ArrayBuffer$1;
|
|
123
123
|
}
|
|
@@ -134,6 +134,16 @@ function isBigInt(value) {
|
|
|
134
134
|
return typeof value === 'bigint';
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
function isObject(value) {
|
|
138
|
+
return typeof value === 'object' && value !== null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const global$7 = getGlobalThis();
|
|
142
|
+
const Blob = global$7.Blob;
|
|
143
|
+
function isBlob(value) {
|
|
144
|
+
return !!Blob && isObject(value) && getTag(value) === 'Blob';
|
|
145
|
+
}
|
|
146
|
+
|
|
137
147
|
function isBoolean(value) {
|
|
138
148
|
return typeof value === 'boolean';
|
|
139
149
|
}
|
|
@@ -142,10 +152,6 @@ const global$6 = getGlobalThis();
|
|
|
142
152
|
const Buffer = global$6.Buffer;
|
|
143
153
|
const isBuffer = (Buffer && Buffer.isBuffer) || (() => false);
|
|
144
154
|
|
|
145
|
-
function isObject(value) {
|
|
146
|
-
return typeof value === 'object' && value !== null;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
155
|
function isDataView(value) {
|
|
150
156
|
return isObject(value) && getTag(value) === 'DataView';
|
|
151
157
|
}
|
|
@@ -155,9 +161,9 @@ function isDate(value) {
|
|
|
155
161
|
}
|
|
156
162
|
|
|
157
163
|
const global$5 = getGlobalThis();
|
|
158
|
-
const File = global$5.File;
|
|
164
|
+
const File$1 = global$5.File;
|
|
159
165
|
function isFile(value) {
|
|
160
|
-
return !!File && value
|
|
166
|
+
return !!File$1 && isObject(value) && getTag(value) === 'File';
|
|
161
167
|
}
|
|
162
168
|
|
|
163
169
|
const global$4 = getGlobalThis();
|
|
@@ -1251,6 +1257,12 @@ function titleCase(str, options) {
|
|
|
1251
1257
|
: ({ code }) => code.slice(0, 1).toUpperCase() + code.slice(1).toLowerCase());
|
|
1252
1258
|
}
|
|
1253
1259
|
|
|
1260
|
+
function capitalize(str) {
|
|
1261
|
+
if (!str)
|
|
1262
|
+
return str;
|
|
1263
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1254
1266
|
function caseConvert(str, joiner = '', handler) {
|
|
1255
1267
|
const hc = handler ? handler : (token) => token.code;
|
|
1256
1268
|
return _caseConvert(_splitVar(str), joiner, hc);
|
|
@@ -1294,10 +1306,55 @@ function caseSnake(str, keepLetterCase = false, keepNumber = true) {
|
|
|
1294
1306
|
return _caseConvert(tokens, '_', keepLetterCase ? ({ code }) => code : ({ code }) => code.toLowerCase());
|
|
1295
1307
|
}
|
|
1296
1308
|
|
|
1309
|
+
function dedent(str, option, indentStr) {
|
|
1310
|
+
if (typeof option === 'number' || indentStr) {
|
|
1311
|
+
return _dedent(str, option || 2, indentStr || ' ');
|
|
1312
|
+
}
|
|
1313
|
+
else {
|
|
1314
|
+
const { count = 2, indentStr = ' ' } = option || {};
|
|
1315
|
+
return _dedent(str, count, indentStr);
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
function _dedent(str, count, indentStr) {
|
|
1319
|
+
return str
|
|
1320
|
+
.split('\n')
|
|
1321
|
+
.map((s) => {
|
|
1322
|
+
let i = count;
|
|
1323
|
+
while (s && s.startsWith(indentStr) && i > 0) {
|
|
1324
|
+
s = s.slice(indentStr.length);
|
|
1325
|
+
i--;
|
|
1326
|
+
}
|
|
1327
|
+
return s;
|
|
1328
|
+
})
|
|
1329
|
+
.join('\n');
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
function indent(str, option, indentStr) {
|
|
1333
|
+
if (typeof option === 'number' || indentStr) {
|
|
1334
|
+
return _indent(str, option || 2, indentStr || ' ', true);
|
|
1335
|
+
}
|
|
1336
|
+
else {
|
|
1337
|
+
const { count = 2, indentStr = ' ', ignoreEmptyLine = true } = option || {};
|
|
1338
|
+
return _indent(str, count, indentStr, ignoreEmptyLine);
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
function _indent(str, count, indentStr, ignoreEmptyLine) {
|
|
1342
|
+
return str
|
|
1343
|
+
.split('\n')
|
|
1344
|
+
.map((s) => `${s || !ignoreEmptyLine ? indentStr.repeat(count) : ''}${s}`)
|
|
1345
|
+
.join('\n');
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1297
1348
|
function splitWords(str) {
|
|
1298
1349
|
return _splitVar(str).map(({ code }) => code);
|
|
1299
1350
|
}
|
|
1300
1351
|
|
|
1352
|
+
function uncapitalize(str) {
|
|
1353
|
+
if (!str)
|
|
1354
|
+
return str;
|
|
1355
|
+
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1301
1358
|
function compose(...composeFunc) {
|
|
1302
1359
|
if (composeFunc.length === 0) {
|
|
1303
1360
|
throw new Error('Invalid composeFunc parameter: composeFunc is empty');
|
|
@@ -1539,6 +1596,16 @@ function _cloneArrayBuffer(obj, map) {
|
|
|
1539
1596
|
new Uint8Array(res).set(new Uint8Array(obj));
|
|
1540
1597
|
return res;
|
|
1541
1598
|
}
|
|
1599
|
+
function _cloneBlob(obj, map) {
|
|
1600
|
+
const res = obj.slice(0, obj.size, obj.type);
|
|
1601
|
+
map.set(obj, res);
|
|
1602
|
+
return res;
|
|
1603
|
+
}
|
|
1604
|
+
function _cloneFile(obj, map) {
|
|
1605
|
+
const res = new File([obj], obj.name, { type: obj.type, lastModified: obj.lastModified });
|
|
1606
|
+
map.set(obj, res);
|
|
1607
|
+
return res;
|
|
1608
|
+
}
|
|
1542
1609
|
|
|
1543
1610
|
function _deepClone(obj, map, options) {
|
|
1544
1611
|
if (map.has(obj))
|
|
@@ -1583,6 +1650,12 @@ function _deepClone(obj, map, options) {
|
|
|
1583
1650
|
res = new DataView(map.has(obj.buffer) ? map.get(obj.buffer) : _cloneArrayBuffer(obj.buffer, map), obj.byteOffset, obj.byteLength);
|
|
1584
1651
|
map.set(obj, res);
|
|
1585
1652
|
}
|
|
1653
|
+
else if (isFile(obj)) {
|
|
1654
|
+
res = _cloneFile(obj, map);
|
|
1655
|
+
}
|
|
1656
|
+
else if (isBlob(obj)) {
|
|
1657
|
+
res = _cloneBlob(obj, map);
|
|
1658
|
+
}
|
|
1586
1659
|
else if (isWrapperObject(obj)) {
|
|
1587
1660
|
res = Object(obj.valueOf());
|
|
1588
1661
|
map.set(obj, res);
|
|
@@ -1617,6 +1690,201 @@ function deepClone(obj, options, map) {
|
|
|
1617
1690
|
return res;
|
|
1618
1691
|
}
|
|
1619
1692
|
|
|
1693
|
+
const $$Empty = Object.freeze({ '@@merge/placeholder': true });
|
|
1694
|
+
function getMergeStrategy(targetType, sourceType, strategy) {
|
|
1695
|
+
return (strategy[`${sourceType}2${targetType}`] ||
|
|
1696
|
+
strategy[`${sourceType}2Any`] ||
|
|
1697
|
+
strategy[`Any2${targetType}`] ||
|
|
1698
|
+
strategy[`Any2Any`] ||
|
|
1699
|
+
'override');
|
|
1700
|
+
}
|
|
1701
|
+
function getBaseMargeType(obj) {
|
|
1702
|
+
if (isMergeEmptyPlaceholder(obj))
|
|
1703
|
+
return 'Empty';
|
|
1704
|
+
const _tag = getTag(obj);
|
|
1705
|
+
if (/Function/.test(_tag))
|
|
1706
|
+
return 'Function';
|
|
1707
|
+
if (/Iterator/.test(_tag))
|
|
1708
|
+
return 'Iterator';
|
|
1709
|
+
if (/(?:8|16|32|64)Array/.test(_tag))
|
|
1710
|
+
return 'TypedArray';
|
|
1711
|
+
if (/Error/.test(_tag))
|
|
1712
|
+
return 'Error';
|
|
1713
|
+
return _tag;
|
|
1714
|
+
}
|
|
1715
|
+
function isMergeEmptyPlaceholder(arg) {
|
|
1716
|
+
return typeof arg === 'object' && Boolean(arg) && arg['@@merge/placeholder'] === true;
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
function _deepMergeBase(target, source, option, map, path, cloner) {
|
|
1720
|
+
const targetType = getBaseMargeType(target);
|
|
1721
|
+
const sourceType = getBaseMargeType(source);
|
|
1722
|
+
const strategy = getMergeStrategy(targetType, sourceType, option.typeStrategy);
|
|
1723
|
+
if (isFunction(strategy)) {
|
|
1724
|
+
const merger = _curryMore(_deepMergeBase)(_, _, option, map, _, cloner);
|
|
1725
|
+
const mergeRes = strategy({
|
|
1726
|
+
target,
|
|
1727
|
+
source,
|
|
1728
|
+
cloner,
|
|
1729
|
+
merger,
|
|
1730
|
+
path,
|
|
1731
|
+
typeStrategy: option.typeStrategy,
|
|
1732
|
+
unhandledValue: $$Empty,
|
|
1733
|
+
map,
|
|
1734
|
+
});
|
|
1735
|
+
if (!isMergeEmptyPlaceholder(mergeRes))
|
|
1736
|
+
return mergeRes;
|
|
1737
|
+
}
|
|
1738
|
+
if (strategy === 'keep') {
|
|
1739
|
+
if (isMergeEmptyPlaceholder(target))
|
|
1740
|
+
return $$Empty;
|
|
1741
|
+
return cloner(target);
|
|
1742
|
+
}
|
|
1743
|
+
else if (strategy === 'override') {
|
|
1744
|
+
return cloner(source);
|
|
1745
|
+
}
|
|
1746
|
+
else {
|
|
1747
|
+
return cloner(source);
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
const defaultMergeStrategy = {
|
|
1751
|
+
Any2Any: 'override',
|
|
1752
|
+
Any2Empty: 'override',
|
|
1753
|
+
Any2Null: 'override',
|
|
1754
|
+
Any2Undefined: 'override',
|
|
1755
|
+
Null2Any: 'keep',
|
|
1756
|
+
Undefined2Any: 'keep',
|
|
1757
|
+
Null2Empty: 'override',
|
|
1758
|
+
Undefined2Empty: 'override',
|
|
1759
|
+
Number2Any: 'keep',
|
|
1760
|
+
Number2Number: 'override',
|
|
1761
|
+
String2Any: 'keep',
|
|
1762
|
+
String2String: 'override',
|
|
1763
|
+
Boolean2Any: 'keep',
|
|
1764
|
+
Boolean2Boolean: 'override',
|
|
1765
|
+
Symbol2Any: 'keep',
|
|
1766
|
+
Symbol2Symbol: 'override',
|
|
1767
|
+
BigInt2Any: 'keep',
|
|
1768
|
+
BigInt2BigInt: 'override',
|
|
1769
|
+
Number2Empty: 'override',
|
|
1770
|
+
String2Empty: 'override',
|
|
1771
|
+
Boolean2Empty: 'override',
|
|
1772
|
+
Symbol2Empty: 'override',
|
|
1773
|
+
BigInt2Empty: 'override',
|
|
1774
|
+
Number2Null: 'override',
|
|
1775
|
+
String2Null: 'override',
|
|
1776
|
+
Boolean2Null: 'override',
|
|
1777
|
+
Symbol2Null: 'override',
|
|
1778
|
+
BigInt2Null: 'override',
|
|
1779
|
+
Number2Undefined: 'override',
|
|
1780
|
+
String2Undefined: 'override',
|
|
1781
|
+
Boolean2Undefined: 'override',
|
|
1782
|
+
Symbol2Undefined: 'override',
|
|
1783
|
+
BigInt2Undefined: 'override',
|
|
1784
|
+
Object2Object: (({ target, source, cloner, path, merger }) => {
|
|
1785
|
+
const res = cloner(target);
|
|
1786
|
+
Reflect.ownKeys(source).forEach((key) => {
|
|
1787
|
+
const newPath = [...path, key];
|
|
1788
|
+
if (key in res) {
|
|
1789
|
+
res[key] = merger(res[key], source[key], newPath);
|
|
1790
|
+
}
|
|
1791
|
+
else {
|
|
1792
|
+
const mergeRes = merger($$Empty, source[key], newPath);
|
|
1793
|
+
if (!isMergeEmptyPlaceholder(mergeRes))
|
|
1794
|
+
res[key] = mergeRes;
|
|
1795
|
+
}
|
|
1796
|
+
});
|
|
1797
|
+
return res;
|
|
1798
|
+
}),
|
|
1799
|
+
Object2FormData: (({ target, source, cloner, path, merger }) => {
|
|
1800
|
+
const res = cloner(target);
|
|
1801
|
+
Reflect.ownKeys(source).forEach((key) => {
|
|
1802
|
+
if (isSymbol(key))
|
|
1803
|
+
return;
|
|
1804
|
+
const newPath = [...path, key];
|
|
1805
|
+
if (res.has(key)) {
|
|
1806
|
+
res.set(key, merger(res.get(key), source[key], newPath));
|
|
1807
|
+
}
|
|
1808
|
+
else {
|
|
1809
|
+
const mergeRes = merger($$Empty, source[key], newPath);
|
|
1810
|
+
if (!isMergeEmptyPlaceholder(mergeRes))
|
|
1811
|
+
res.set(key, mergeRes);
|
|
1812
|
+
}
|
|
1813
|
+
});
|
|
1814
|
+
return res;
|
|
1815
|
+
}),
|
|
1816
|
+
FormData2Object: (({ target, source, cloner, path, merger }) => {
|
|
1817
|
+
const res = cloner(target);
|
|
1818
|
+
source.forEach((val, key) => {
|
|
1819
|
+
const newPath = [...path, key];
|
|
1820
|
+
if (key in res) {
|
|
1821
|
+
res[key] = merger(res[key], val, newPath);
|
|
1822
|
+
}
|
|
1823
|
+
else {
|
|
1824
|
+
const mergeRes = merger($$Empty, val, newPath);
|
|
1825
|
+
if (!isMergeEmptyPlaceholder(mergeRes))
|
|
1826
|
+
res[key] = mergeRes;
|
|
1827
|
+
}
|
|
1828
|
+
});
|
|
1829
|
+
return res;
|
|
1830
|
+
}),
|
|
1831
|
+
FormData2FormData: (({ target, source, cloner, path, merger }) => {
|
|
1832
|
+
const res = cloner(target);
|
|
1833
|
+
source.forEach((val, key) => {
|
|
1834
|
+
const newPath = [...path, key];
|
|
1835
|
+
if (res.has(key)) {
|
|
1836
|
+
res.set(key, merger(res.get(key), val, newPath));
|
|
1837
|
+
}
|
|
1838
|
+
else {
|
|
1839
|
+
const mergeRes = merger($$Empty, val, newPath);
|
|
1840
|
+
if (!isMergeEmptyPlaceholder(mergeRes))
|
|
1841
|
+
res.set(key, mergeRes);
|
|
1842
|
+
}
|
|
1843
|
+
});
|
|
1844
|
+
return res;
|
|
1845
|
+
}),
|
|
1846
|
+
Set2Set: (({ target, source, cloner }) => {
|
|
1847
|
+
const res = cloner(target);
|
|
1848
|
+
for (const item of source)
|
|
1849
|
+
res.add(cloner(item));
|
|
1850
|
+
return res;
|
|
1851
|
+
}),
|
|
1852
|
+
Map2Map: (({ target, source, cloner }) => {
|
|
1853
|
+
const res = cloner(target);
|
|
1854
|
+
for (const [key, val] of source)
|
|
1855
|
+
res.set(cloner(key), cloner(val));
|
|
1856
|
+
return res;
|
|
1857
|
+
}),
|
|
1858
|
+
Array2Array: (({ target, source, cloner }) => {
|
|
1859
|
+
const res = cloner(target);
|
|
1860
|
+
for (const item of source)
|
|
1861
|
+
res.push(cloner(item));
|
|
1862
|
+
return res;
|
|
1863
|
+
}),
|
|
1864
|
+
Set2Array: (({ target, source, cloner }) => {
|
|
1865
|
+
const res = cloner(target);
|
|
1866
|
+
for (const item of source)
|
|
1867
|
+
res.push(cloner(item));
|
|
1868
|
+
return res;
|
|
1869
|
+
}),
|
|
1870
|
+
Array2Set: (({ target, source, cloner }) => {
|
|
1871
|
+
const res = cloner(target);
|
|
1872
|
+
for (const item of source)
|
|
1873
|
+
res.add(cloner(item));
|
|
1874
|
+
return res;
|
|
1875
|
+
}),
|
|
1876
|
+
};
|
|
1877
|
+
|
|
1878
|
+
function deepMerge(target, source, option) {
|
|
1879
|
+
const typeStrategy = Object.assign(Object.assign({}, defaultMergeStrategy), ((option === null || option === void 0 ? void 0 : option.typeStrategy) || {}));
|
|
1880
|
+
const cloneOptions = Object.assign({ cloneSymbol: true, clonePrototype: false, cloneDescriptor: false, customCloner: [] }, ((option === null || option === void 0 ? void 0 : option.cloneOptions) || {}));
|
|
1881
|
+
const map = new Map();
|
|
1882
|
+
const cloner = _curryMore(_deepClone)(_, map, cloneOptions);
|
|
1883
|
+
const res = _deepMergeBase(target, source, { typeStrategy, cloneOptions }, map, [], cloner);
|
|
1884
|
+
map.clear();
|
|
1885
|
+
return res;
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1620
1888
|
function _fastClone(obj, map) {
|
|
1621
1889
|
if (map.has(obj))
|
|
1622
1890
|
return map.get(obj);
|
|
@@ -1774,10 +2042,12 @@ function throttle(fn, delay, options) {
|
|
|
1774
2042
|
return _throttle(fn, delay, Object.assign({ trailing: false, leading: true }, options));
|
|
1775
2043
|
}
|
|
1776
2044
|
|
|
2045
|
+
exports.$$Empty = $$Empty;
|
|
1777
2046
|
exports._ = _;
|
|
1778
2047
|
exports.acceptableFileName = acceptableFileName;
|
|
1779
2048
|
exports.acceptableFileType = acceptableFileType;
|
|
1780
2049
|
exports.camelCase = camelCase;
|
|
2050
|
+
exports.capitalize = capitalize;
|
|
1781
2051
|
exports.caseCamel = caseCamel;
|
|
1782
2052
|
exports.caseConvert = caseConvert;
|
|
1783
2053
|
exports.caseKebab = caseKebab;
|
|
@@ -1787,19 +2057,23 @@ exports.clamp = clamp;
|
|
|
1787
2057
|
exports.compose = compose;
|
|
1788
2058
|
exports.curry = _curryMore;
|
|
1789
2059
|
exports.debounce = debounce;
|
|
2060
|
+
exports.dedent = dedent;
|
|
1790
2061
|
exports.deepClone = deepClone;
|
|
2062
|
+
exports.deepMerge = deepMerge;
|
|
1791
2063
|
exports.defer = defer;
|
|
1792
2064
|
exports.fastClone = fastClone;
|
|
1793
2065
|
exports.getAcceptableExtByMIME = getAcceptableExtByMIME;
|
|
1794
2066
|
exports.getAcceptableMIMEByExt = getAcceptableMIMEByExt;
|
|
1795
2067
|
exports.getGlobalThis = getGlobalThis;
|
|
1796
2068
|
exports.getTag = getTag;
|
|
2069
|
+
exports.indent = indent;
|
|
1797
2070
|
exports.isArray = isArray;
|
|
1798
2071
|
exports.isArrayBuffer = isArrayBuffer;
|
|
1799
2072
|
exports.isArrayLike = isArrayLike;
|
|
1800
2073
|
exports.isBigInt = isBigInt;
|
|
1801
2074
|
exports.isBigInt64Array = isBigInt64Array;
|
|
1802
2075
|
exports.isBigUint64Array = isBigUint64Array;
|
|
2076
|
+
exports.isBlob = isBlob;
|
|
1803
2077
|
exports.isBoolean = isBoolean;
|
|
1804
2078
|
exports.isBuffer = isBuffer;
|
|
1805
2079
|
exports.isDataView = isDataView;
|
|
@@ -1816,6 +2090,7 @@ exports.isInt8Array = isInt8Array;
|
|
|
1816
2090
|
exports.isInteger = isInteger;
|
|
1817
2091
|
exports.isIterable = isIterable;
|
|
1818
2092
|
exports.isMap = isMap;
|
|
2093
|
+
exports.isMergeEmptyPlaceholder = isMergeEmptyPlaceholder;
|
|
1819
2094
|
exports.isNil = isNil;
|
|
1820
2095
|
exports.isNull = isNull;
|
|
1821
2096
|
exports.isNumber = isNumber;
|
|
@@ -1868,6 +2143,7 @@ exports.throttle = throttle;
|
|
|
1868
2143
|
exports.titleCase = titleCase;
|
|
1869
2144
|
exports.tryit = tryit;
|
|
1870
2145
|
exports.ulid = ulid;
|
|
2146
|
+
exports.uncapitalize = uncapitalize;
|
|
1871
2147
|
exports.uuidNil = uuidNil;
|
|
1872
2148
|
exports.uuidV4 = uuidV4;
|
|
1873
2149
|
exports.withResolvers = withResolvers;
|