@maiyunnet/kebab 3.2.27 → 3.2.28
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/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/text.js +21 -7
- package/package.json +1 -1
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
7
7
|
*/
|
|
8
8
|
/** --- 当前系统版本号 --- */
|
|
9
|
-
export const VER = '3.2.
|
|
9
|
+
export const VER = '3.2.28';
|
|
10
10
|
// --- 服务端用的路径 ---
|
|
11
11
|
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
|
|
12
12
|
/** --- /xxx/xxx --- */
|
package/lib/text.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import * as kebab from '#kebab/index.js';
|
|
7
7
|
import * as lFs from './fs.js';
|
|
8
|
+
import * as lCore from './core.js';
|
|
8
9
|
/**
|
|
9
10
|
* --- 将文件大小格式化为带单位的字符串 ---
|
|
10
11
|
* @param size 文件大小
|
|
@@ -521,18 +522,31 @@ export function stringifyBuffer(buf) {
|
|
|
521
522
|
* --- 递归删除 json 中的字符串首尾空格,会返回一个新的对象 ---
|
|
522
523
|
*/
|
|
523
524
|
export function trimJson(json) {
|
|
524
|
-
json =
|
|
525
|
+
json = lCore.clone(json);
|
|
525
526
|
trimJsonRecursion(json);
|
|
526
527
|
return json;
|
|
527
528
|
}
|
|
528
529
|
function trimJsonRecursion(json) {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
530
|
+
if (Array.isArray(json)) {
|
|
531
|
+
for (let i = 0; i < json.length; ++i) {
|
|
532
|
+
const val = json[i];
|
|
533
|
+
if (typeof val === 'string') {
|
|
534
|
+
json[i] = val.trim();
|
|
535
|
+
}
|
|
536
|
+
else if (typeof val === 'object') {
|
|
537
|
+
trimJsonRecursion(val);
|
|
538
|
+
}
|
|
533
539
|
}
|
|
534
|
-
|
|
535
|
-
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
for (const key in json) {
|
|
543
|
+
const val = json[key];
|
|
544
|
+
if (typeof val === 'string') {
|
|
545
|
+
json[key] = val.trim();
|
|
546
|
+
}
|
|
547
|
+
else if (typeof val === 'object') {
|
|
548
|
+
trimJsonRecursion(val);
|
|
549
|
+
}
|
|
536
550
|
}
|
|
537
551
|
}
|
|
538
552
|
}
|