mingyang_text 2023.2.1 → 2023.2.8
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 +28 -2
package/package.json
CHANGED
package/text.js
CHANGED
@@ -420,13 +420,38 @@ 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_DelimiterArray
|
430
|
+
*/
|
431
|
+
function func_Split(args_Text, args_DelimiterArray = [",", "-", "/", "|", "~", "*", "+"]) {
|
432
|
+
let temp_Result = [args_Text];
|
433
|
+
for (let u = 0; u < args_DelimiterArray.length; u++) {
|
434
|
+
if (args_Text.indexOf(args_DelimiterArray[u]) > -1) {
|
435
|
+
temp_Result = args_Text.split(args_DelimiterArray[u]);
|
436
|
+
temp_Result["delimiter"] = args_DelimiterArray[u];
|
437
|
+
break;
|
438
|
+
}
|
439
|
+
}
|
440
|
+
return temp_Result;
|
441
|
+
}
|
442
|
+
module.exports.do_Split = func_Split;
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
|
423
448
|
/**
|
424
449
|
* 按照字节长度截取字符串
|
425
450
|
* @param {"原始字符"} args_InputString
|
426
451
|
* @param {"目标长度"} args_ByteLength
|
427
452
|
* @param {"编码方式"} args_Encoding
|
428
453
|
*/
|
429
|
-
|
454
|
+
function func_Byte_Truncate(args_InputString, args_ByteLength, args_Encoding = "utf8") {
|
430
455
|
let temp_Description = args_InputString.substring(0, args_ByteLength);
|
431
456
|
let temp_Buffer = Buffer.from(temp_Description, args_Encoding);
|
432
457
|
while (temp_Buffer.length > args_ByteLength) {
|
@@ -434,4 +459,5 @@ module.exports.do_Byte_Truncate = (args_InputString, args_ByteLength, args_Encod
|
|
434
459
|
temp_Buffer = Buffer.from(temp_Description, args_Encoding);
|
435
460
|
}
|
436
461
|
return temp_Description;
|
437
|
-
}
|
462
|
+
}
|
463
|
+
module.exports.do_Byte_Truncate = func_Byte_Truncate;
|