@pawover/kit 0.0.0-beta.1 → 0.0.0-beta.3
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/dist/hooks-react.js +10 -4
- package/dist/hooks-react.js.map +1 -1
- package/dist/index.d.ts +51 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +79 -23
- package/dist/index.js.map +1 -1
- package/dist/patches-fetchEventSource.d.ts.map +1 -1
- package/dist/patches-fetchEventSource.js +7 -7
- package/dist/patches-fetchEventSource.js.map +1 -1
- package/metadata.json +3 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -99,8 +99,8 @@ function isClass(value) {
|
|
|
99
99
|
* 判断是否为对象类型
|
|
100
100
|
* - 可选是否检查原型为 `Object.prototype`,防止原型链污染
|
|
101
101
|
*
|
|
102
|
-
* @param value
|
|
103
|
-
* @param prototypeCheck
|
|
102
|
+
* @param value 待检查值
|
|
103
|
+
* @param prototypeCheck 是否进行原型检查,默认 `true`
|
|
104
104
|
*/
|
|
105
105
|
function isObject(value, prototypeCheck = true) {
|
|
106
106
|
const check = resolvePrototypeString(value) === PROTOTYPE_TAGS.object;
|
|
@@ -206,8 +206,8 @@ function isNull(value) {
|
|
|
206
206
|
/**
|
|
207
207
|
* 检查 value 是否为 number 类型
|
|
208
208
|
*
|
|
209
|
-
* @param value
|
|
210
|
-
* @param checkNaN
|
|
209
|
+
* @param value 待检查值
|
|
210
|
+
* @param checkNaN 是否排除 `NaN`,默认为 `true`
|
|
211
211
|
*/
|
|
212
212
|
function isNumber(value, checkNaN = true) {
|
|
213
213
|
return typeof value === "number" && (!checkNaN || !isNaN(value));
|
|
@@ -215,7 +215,7 @@ function isNumber(value, checkNaN = true) {
|
|
|
215
215
|
/**
|
|
216
216
|
* 检查 value 是否为 NaN
|
|
217
217
|
*
|
|
218
|
-
* @param value
|
|
218
|
+
* @param value 待检查值
|
|
219
219
|
*/
|
|
220
220
|
function isNaN(value) {
|
|
221
221
|
return Number.isNaN(value);
|
|
@@ -223,8 +223,8 @@ function isNaN(value) {
|
|
|
223
223
|
/**
|
|
224
224
|
* 检查 value 是否为整数
|
|
225
225
|
*
|
|
226
|
-
* @param value
|
|
227
|
-
* @param safeCheck
|
|
226
|
+
* @param value 待检查值
|
|
227
|
+
* @param safeCheck 是否附加安全数检查
|
|
228
228
|
*/
|
|
229
229
|
function isInteger(value, safeCheck = true) {
|
|
230
230
|
const check = Number.isInteger(value);
|
|
@@ -234,8 +234,8 @@ function isInteger(value, safeCheck = true) {
|
|
|
234
234
|
* 检查 value 是否为正整数
|
|
235
235
|
* - 此函数中 `0` 不被视为正整数
|
|
236
236
|
*
|
|
237
|
-
* @param value
|
|
238
|
-
* @param safeCheck
|
|
237
|
+
* @param value 待检查值
|
|
238
|
+
* @param safeCheck 是否附加安全数检查
|
|
239
239
|
*/
|
|
240
240
|
function isPositiveInteger(value, safeCheck = true) {
|
|
241
241
|
return isInteger(value, safeCheck) && value > 0;
|
|
@@ -244,8 +244,8 @@ function isPositiveInteger(value, safeCheck = true) {
|
|
|
244
244
|
* 检查 value 是否为负整数
|
|
245
245
|
* - 此函数中 `0` 不被视为负整数
|
|
246
246
|
*
|
|
247
|
-
* @param value
|
|
248
|
-
* @param safeCheck
|
|
247
|
+
* @param value 待检查值
|
|
248
|
+
* @param safeCheck 是否附加安全数检查
|
|
249
249
|
*/
|
|
250
250
|
function isNegativeInteger(value, safeCheck = true) {
|
|
251
251
|
return isInteger(value, safeCheck) && value < 0;
|
|
@@ -254,7 +254,7 @@ function isNegativeInteger(value, safeCheck = true) {
|
|
|
254
254
|
* 检查 value 是否为 Infinity
|
|
255
255
|
* - 排除 `NaN`
|
|
256
256
|
*
|
|
257
|
-
* @param value
|
|
257
|
+
* @param value 待检查值
|
|
258
258
|
*/
|
|
259
259
|
function isInfinity(value) {
|
|
260
260
|
return isNumber(value) && (Number.POSITIVE_INFINITY === value || Number.NEGATIVE_INFINITY === value);
|
|
@@ -263,7 +263,7 @@ function isInfinity(value) {
|
|
|
263
263
|
* 检查 value 是否类似 Infinity
|
|
264
264
|
* - 排除 `NaN`
|
|
265
265
|
*
|
|
266
|
-
* @param value
|
|
266
|
+
* @param value 待检查值
|
|
267
267
|
*/
|
|
268
268
|
function isInfinityLike(value) {
|
|
269
269
|
const check = isInfinity(value);
|
|
@@ -323,8 +323,14 @@ function isWeakSet(value) {
|
|
|
323
323
|
|
|
324
324
|
//#endregion
|
|
325
325
|
//#region src/utils/typeof/isString.ts
|
|
326
|
-
|
|
327
|
-
|
|
326
|
+
/**
|
|
327
|
+
* 检查 value 是否为 string 类型
|
|
328
|
+
*
|
|
329
|
+
* @param value 待检查值
|
|
330
|
+
* @param checkEmpty 是否排除空字符串
|
|
331
|
+
*/
|
|
332
|
+
function isString(value, checkEmpty = false) {
|
|
333
|
+
return typeof value === "string" && (!checkEmpty || !!value.length);
|
|
328
334
|
}
|
|
329
335
|
|
|
330
336
|
//#endregion
|
|
@@ -567,7 +573,7 @@ function arraySplit(initialList, size = 10) {
|
|
|
567
573
|
//#region src/utils/function/to.ts
|
|
568
574
|
/**
|
|
569
575
|
* @param promise
|
|
570
|
-
* @param errorExt
|
|
576
|
+
* @param errorExt 可以传递给err对象的其他信息
|
|
571
577
|
*/
|
|
572
578
|
function to(promise, errorExt) {
|
|
573
579
|
return promise.then((data) => [null, data]).catch((err) => {
|
|
@@ -588,7 +594,7 @@ const R1$1 = /[^0-9.-]/g;
|
|
|
588
594
|
* @param input 待处理字符串
|
|
589
595
|
*/
|
|
590
596
|
function stringToNumber(input) {
|
|
591
|
-
if (!isString(input
|
|
597
|
+
if (!isString(input, true)) return "";
|
|
592
598
|
const cleaned = input.replace(R1$1, "");
|
|
593
599
|
let isDecimal = false;
|
|
594
600
|
let signCount = 0;
|
|
@@ -887,7 +893,7 @@ const R2 = /[^a-zA-Z\u00C0-\u017F]/;
|
|
|
887
893
|
* @param caseType 大小写类型
|
|
888
894
|
*/
|
|
889
895
|
function stringInitialCase(input, caseType) {
|
|
890
|
-
if (!isString(input
|
|
896
|
+
if (!isString(input, true)) return "";
|
|
891
897
|
return input.replace(R1, (word) => {
|
|
892
898
|
if (R2.test(word)) return word;
|
|
893
899
|
if (word === word.toLocaleUpperCase()) return word;
|
|
@@ -908,7 +914,7 @@ function stringInitialCase(input, caseType) {
|
|
|
908
914
|
* @param replacement 替换项
|
|
909
915
|
*/
|
|
910
916
|
function stringReplace(input, search, replacement) {
|
|
911
|
-
if (!isString(input
|
|
917
|
+
if (!isString(input, true)) return "";
|
|
912
918
|
return input.replace(search, replacement);
|
|
913
919
|
}
|
|
914
920
|
|
|
@@ -922,7 +928,7 @@ function stringReplace(input, search, replacement) {
|
|
|
922
928
|
* @param regex 模板匹配正则
|
|
923
929
|
*/
|
|
924
930
|
function stringTemplate(input, template, regex = /\{\{(.+?)\}\}/g) {
|
|
925
|
-
if (!isString(input
|
|
931
|
+
if (!isString(input, true)) return "";
|
|
926
932
|
let result = "";
|
|
927
933
|
let from = 0;
|
|
928
934
|
let match;
|
|
@@ -942,7 +948,7 @@ function stringTemplate(input, template, regex = /\{\{(.+?)\}\}/g) {
|
|
|
942
948
|
* @param safeValue 安全值
|
|
943
949
|
*/
|
|
944
950
|
function stringToJson(input, safeValue) {
|
|
945
|
-
if (!isString(input
|
|
951
|
+
if (!isString(input, true)) return safeValue;
|
|
946
952
|
try {
|
|
947
953
|
return JSON.parse(input);
|
|
948
954
|
} catch (error) {
|
|
@@ -950,10 +956,27 @@ function stringToJson(input, safeValue) {
|
|
|
950
956
|
}
|
|
951
957
|
}
|
|
952
958
|
|
|
959
|
+
//#endregion
|
|
960
|
+
//#region src/utils/string/stringToPosix.ts
|
|
961
|
+
/**
|
|
962
|
+
* 将路径转换为 POSIX 风格
|
|
963
|
+
*
|
|
964
|
+
* @param input 待处理字符串
|
|
965
|
+
* @param removeLeadingSlash 是否移除开头斜杠,默认为 `false`
|
|
966
|
+
*/
|
|
967
|
+
function stringToPosix(input, removeLeadingSlash = false) {
|
|
968
|
+
if (!isString(input, true)) return "";
|
|
969
|
+
let normalized = input.replace(/^[A-Za-z]:[\\/]?/, "").replace(/^[\\/]+/, "");
|
|
970
|
+
normalized = normalized.replace(/\\/g, "/");
|
|
971
|
+
normalized = normalized.replace(/\/+/g, "/");
|
|
972
|
+
if (removeLeadingSlash && normalized.startsWith("/")) normalized = normalized.substring(1);
|
|
973
|
+
return normalized;
|
|
974
|
+
}
|
|
975
|
+
|
|
953
976
|
//#endregion
|
|
954
977
|
//#region src/utils/string/stringToValues.ts
|
|
955
978
|
function stringToValues(input, valueType = "number", splitSymbol = ",") {
|
|
956
|
-
if (!isString(input
|
|
979
|
+
if (!isString(input, true)) return [];
|
|
957
980
|
try {
|
|
958
981
|
const values = input.split(splitSymbol);
|
|
959
982
|
if (valueType === "number") return values.map((d) => Number(d));
|
|
@@ -963,6 +986,39 @@ function stringToValues(input, valueType = "number", splitSymbol = ",") {
|
|
|
963
986
|
}
|
|
964
987
|
}
|
|
965
988
|
|
|
989
|
+
//#endregion
|
|
990
|
+
//#region src/utils/string/stringTrim.ts
|
|
991
|
+
/**
|
|
992
|
+
* 从字符串中裁切掉所有的前缀和后缀字符
|
|
993
|
+
*
|
|
994
|
+
* @param input 待处理字符串
|
|
995
|
+
* @param charsToTrim 裁切字符,默认为 `" "`
|
|
996
|
+
*/
|
|
997
|
+
function stringTrim(input, charsToTrim = " ") {
|
|
998
|
+
if (!isString(input, true)) return "";
|
|
999
|
+
const toTrim = charsToTrim.replace(/[\W]{1}/g, "\\$&");
|
|
1000
|
+
const regex = new RegExp(`^[${toTrim}]+|[${toTrim}]+$`, "g");
|
|
1001
|
+
return input.replace(regex, "");
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
//#endregion
|
|
1005
|
+
//#region src/utils/string/stringTruncate.ts
|
|
1006
|
+
/**
|
|
1007
|
+
* 截取字符串
|
|
1008
|
+
* - 支持中英文混排,不会在汉字中间截断
|
|
1009
|
+
*
|
|
1010
|
+
* @param input 待处理字符串
|
|
1011
|
+
* @param maxLength 最大长度
|
|
1012
|
+
* @param ellipsis 省略符,默认为 `...`
|
|
1013
|
+
*/
|
|
1014
|
+
function stringTruncate(input, maxLength, ellipsis = "...") {
|
|
1015
|
+
if (!isString(input, true)) return "";
|
|
1016
|
+
if (!isPositiveInteger(maxLength)) return input;
|
|
1017
|
+
if (input.length <= maxLength) return input;
|
|
1018
|
+
const truncated = input.slice(0, maxLength - ellipsis.length);
|
|
1019
|
+
return truncated.length > 0 ? truncated + ellipsis : "";
|
|
1020
|
+
}
|
|
1021
|
+
|
|
966
1022
|
//#endregion
|
|
967
1023
|
//#region src/utils/tree/types.ts
|
|
968
1024
|
function getFinalChildrenKey(tree, meta, options) {
|
|
@@ -1371,5 +1427,5 @@ function treeToRows(tree, options = {}) {
|
|
|
1371
1427
|
}
|
|
1372
1428
|
|
|
1373
1429
|
//#endregion
|
|
1374
|
-
export { arrayCast, arrayCompete, arrayCounting, arrayDifference, arrayFirst, arrayFork, arrayIntersection, arrayLast, arrayMerge, arrayPick, arrayReplace, arraySplit, cloneDeep, enumEntries, enumKeys, enumTypeCheck, enumValues, isAbortSignal, isArray, isAsyncFunction, isAsyncGeneratorFunction, isBigInt, isBlob, isBoolean, isClass, isDate, isEqual, isError, isFalsy, isFalsyLike, isFile, isFunction, isGeneratorFunction, isInfinity, isInfinityLike, isInteger, isIterable, isMap, isNaN, isNegativeInteger, isNull, isNumber, isObject, isPositiveInteger, isPromise, isPromiseLike, isReadableStream, isRegExp, isSet, isString, isSymbol, isTypedArray, isURLSearchParams, isUndefined, isWeakMap, isWeakSet, isWebSocket, isWindow, mapEntries, objectAssign, objectCrush, objectEntries, objectKeys, objectPick, objectSwitch, objectValues, rowsToTree, stringInitialCase, stringReplace, stringTemplate, stringToJson, stringToNumber, stringToValues, to, toMathBignumber, toMathDecimal, toMathEvaluate, treeFilter, treeFind, treeForEach, treeMap, treeToRows };
|
|
1430
|
+
export { arrayCast, arrayCompete, arrayCounting, arrayDifference, arrayFirst, arrayFork, arrayIntersection, arrayLast, arrayMerge, arrayPick, arrayReplace, arraySplit, cloneDeep, enumEntries, enumKeys, enumTypeCheck, enumValues, isAbortSignal, isArray, isAsyncFunction, isAsyncGeneratorFunction, isBigInt, isBlob, isBoolean, isClass, isDate, isEqual, isError, isFalsy, isFalsyLike, isFile, isFunction, isGeneratorFunction, isInfinity, isInfinityLike, isInteger, isIterable, isMap, isNaN, isNegativeInteger, isNull, isNumber, isObject, isPositiveInteger, isPromise, isPromiseLike, isReadableStream, isRegExp, isSet, isString, isSymbol, isTypedArray, isURLSearchParams, isUndefined, isWeakMap, isWeakSet, isWebSocket, isWindow, mapEntries, objectAssign, objectCrush, objectEntries, objectKeys, objectPick, objectSwitch, objectValues, rowsToTree, stringInitialCase, stringReplace, stringTemplate, stringToJson, stringToNumber, stringToPosix, stringToValues, stringTrim, stringTruncate, to, toMathBignumber, toMathDecimal, toMathEvaluate, treeFilter, treeFind, treeForEach, treeMap, treeToRows };
|
|
1375
1431
|
//# sourceMappingURL=index.js.map
|