mingyang_text 2023.2.1 → 2023.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/text.js +27 -2
package/package.json
CHANGED
package/text.js
CHANGED
@@ -420,13 +420,37 @@ function func_Base62Decode(args_Base62Number) {
|
|
420
420
|
module.exports.do_Base62Decode = func_Base62Decode;
|
421
421
|
|
422
422
|
|
423
|
+
|
424
|
+
|
425
|
+
|
426
|
+
/**
|
427
|
+
* 按照一定的顺序尝试分割字符串
|
428
|
+
* @param {原始字符串} args_Text
|
429
|
+
* @param {分隔符数组} args_Spliter
|
430
|
+
*/
|
431
|
+
function func_Split(args_Text, args_Spliter = [",", "-", "/", "|", "~", "*", "+"]) {
|
432
|
+
let temp_Result = [args_Text];
|
433
|
+
for (let u = 0; u < args_Spliter.length; u++) {
|
434
|
+
if (args_Text.indexOf(args_Spliter[u]) > -1) {
|
435
|
+
temp_Result = args_Text.split(args_Spliter[u]);
|
436
|
+
break;
|
437
|
+
}
|
438
|
+
}
|
439
|
+
return temp_Result;
|
440
|
+
}
|
441
|
+
module.exports.do_Split = func_Split;
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
|
423
447
|
/**
|
424
448
|
* 按照字节长度截取字符串
|
425
449
|
* @param {"原始字符"} args_InputString
|
426
450
|
* @param {"目标长度"} args_ByteLength
|
427
451
|
* @param {"编码方式"} args_Encoding
|
428
452
|
*/
|
429
|
-
|
453
|
+
function func_Byte_Truncate(args_InputString, args_ByteLength, args_Encoding = "utf8") {
|
430
454
|
let temp_Description = args_InputString.substring(0, args_ByteLength);
|
431
455
|
let temp_Buffer = Buffer.from(temp_Description, args_Encoding);
|
432
456
|
while (temp_Buffer.length > args_ByteLength) {
|
@@ -434,4 +458,5 @@ module.exports.do_Byte_Truncate = (args_InputString, args_ByteLength, args_Encod
|
|
434
458
|
temp_Buffer = Buffer.from(temp_Description, args_Encoding);
|
435
459
|
}
|
436
460
|
return temp_Description;
|
437
|
-
}
|
461
|
+
}
|
462
|
+
module.exports.do_Byte_Truncate = func_Byte_Truncate;
|