@jhqn/utils-core 0.0.3-beta.4 → 0.0.3-beta.5
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/index.cjs +10 -7
- package/dist/index.d.cts +0 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +10 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -115,22 +115,24 @@ const isURL = (val) => getVariableType(val) === "url";
|
|
|
115
115
|
const isError = (val) => getVariableType(val) === "error";
|
|
116
116
|
const isDef = (val) => !isNull(val) && !isUndefined(val);
|
|
117
117
|
const isJSONStr = (str) => {
|
|
118
|
-
if (isDef(str))
|
|
118
|
+
if (isDef(str)) {
|
|
119
119
|
try {
|
|
120
120
|
JSON.parse(str);
|
|
121
121
|
return true;
|
|
122
122
|
} catch (e) {
|
|
123
123
|
return false;
|
|
124
124
|
}
|
|
125
|
+
}
|
|
125
126
|
return false;
|
|
126
127
|
};
|
|
127
128
|
const isArrStr = (str) => {
|
|
128
|
-
if (isDef(str))
|
|
129
|
+
if (isDef(str)) {
|
|
129
130
|
try {
|
|
130
131
|
return Array.isArray(JSON.parse(str));
|
|
131
132
|
} catch (e) {
|
|
132
133
|
return false;
|
|
133
134
|
}
|
|
135
|
+
}
|
|
134
136
|
return false;
|
|
135
137
|
};
|
|
136
138
|
const isValidKey = (key, object) => key in object;
|
|
@@ -415,11 +417,11 @@ const recoverFile = (resource) => {
|
|
|
415
417
|
const attachFmt = (data) => {
|
|
416
418
|
let attachList = [];
|
|
417
419
|
const prototype = Object.prototype.toString.call(data);
|
|
418
|
-
if (!data)
|
|
420
|
+
if (!data) {
|
|
419
421
|
attachList = [];
|
|
420
|
-
else if (Array.isArray(data))
|
|
422
|
+
} else if (Array.isArray(data)) {
|
|
421
423
|
attachList = data.filter(Boolean);
|
|
422
|
-
else if (typeof data === "string") {
|
|
424
|
+
} else if (typeof data === "string") {
|
|
423
425
|
if (isArrStr(data)) {
|
|
424
426
|
attachList = (parseToJSON(data) || []).filter(Boolean);
|
|
425
427
|
} else {
|
|
@@ -430,8 +432,9 @@ const attachFmt = (data) => {
|
|
|
430
432
|
else
|
|
431
433
|
attachList = [{ id: data, name: "name", uri: data, group: "default" }];
|
|
432
434
|
}
|
|
433
|
-
} else if (prototype === "[object Object]")
|
|
435
|
+
} else if (prototype === "[object Object]") {
|
|
434
436
|
attachList = [data];
|
|
437
|
+
}
|
|
435
438
|
return attachList.map(recoverFile);
|
|
436
439
|
};
|
|
437
440
|
|
|
@@ -456,7 +459,7 @@ const getHostEnv = () => {
|
|
|
456
459
|
const ua = userAgent.toLowerCase();
|
|
457
460
|
const zlb = ua.includes("@zlb");
|
|
458
461
|
const zyd = ua.includes("saas");
|
|
459
|
-
const zzd = ua.includes("zhejiang") || ua.includes("tauruszjd");
|
|
462
|
+
const zzd = ua.includes("zhejiang") || ua.includes("tauruszjd") || ua.includes("dingtalk-win");
|
|
460
463
|
const wx = ua.includes("micromessenger");
|
|
461
464
|
const zfb = ua.includes("alipay");
|
|
462
465
|
const mini = ua.includes("miniprogram");
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -104,22 +104,24 @@ const isURL = (val) => getVariableType(val) === "url";
|
|
|
104
104
|
const isError = (val) => getVariableType(val) === "error";
|
|
105
105
|
const isDef = (val) => !isNull(val) && !isUndefined(val);
|
|
106
106
|
const isJSONStr = (str) => {
|
|
107
|
-
if (isDef(str))
|
|
107
|
+
if (isDef(str)) {
|
|
108
108
|
try {
|
|
109
109
|
JSON.parse(str);
|
|
110
110
|
return true;
|
|
111
111
|
} catch (e) {
|
|
112
112
|
return false;
|
|
113
113
|
}
|
|
114
|
+
}
|
|
114
115
|
return false;
|
|
115
116
|
};
|
|
116
117
|
const isArrStr = (str) => {
|
|
117
|
-
if (isDef(str))
|
|
118
|
+
if (isDef(str)) {
|
|
118
119
|
try {
|
|
119
120
|
return Array.isArray(JSON.parse(str));
|
|
120
121
|
} catch (e) {
|
|
121
122
|
return false;
|
|
122
123
|
}
|
|
124
|
+
}
|
|
123
125
|
return false;
|
|
124
126
|
};
|
|
125
127
|
const isValidKey = (key, object) => key in object;
|
|
@@ -404,11 +406,11 @@ const recoverFile = (resource) => {
|
|
|
404
406
|
const attachFmt = (data) => {
|
|
405
407
|
let attachList = [];
|
|
406
408
|
const prototype = Object.prototype.toString.call(data);
|
|
407
|
-
if (!data)
|
|
409
|
+
if (!data) {
|
|
408
410
|
attachList = [];
|
|
409
|
-
else if (Array.isArray(data))
|
|
411
|
+
} else if (Array.isArray(data)) {
|
|
410
412
|
attachList = data.filter(Boolean);
|
|
411
|
-
else if (typeof data === "string") {
|
|
413
|
+
} else if (typeof data === "string") {
|
|
412
414
|
if (isArrStr(data)) {
|
|
413
415
|
attachList = (parseToJSON(data) || []).filter(Boolean);
|
|
414
416
|
} else {
|
|
@@ -419,8 +421,9 @@ const attachFmt = (data) => {
|
|
|
419
421
|
else
|
|
420
422
|
attachList = [{ id: data, name: "name", uri: data, group: "default" }];
|
|
421
423
|
}
|
|
422
|
-
} else if (prototype === "[object Object]")
|
|
424
|
+
} else if (prototype === "[object Object]") {
|
|
423
425
|
attachList = [data];
|
|
426
|
+
}
|
|
424
427
|
return attachList.map(recoverFile);
|
|
425
428
|
};
|
|
426
429
|
|
|
@@ -445,7 +448,7 @@ const getHostEnv = () => {
|
|
|
445
448
|
const ua = userAgent.toLowerCase();
|
|
446
449
|
const zlb = ua.includes("@zlb");
|
|
447
450
|
const zyd = ua.includes("saas");
|
|
448
|
-
const zzd = ua.includes("zhejiang") || ua.includes("tauruszjd");
|
|
451
|
+
const zzd = ua.includes("zhejiang") || ua.includes("tauruszjd") || ua.includes("dingtalk-win");
|
|
449
452
|
const wx = ua.includes("micromessenger");
|
|
450
453
|
const zfb = ua.includes("alipay");
|
|
451
454
|
const mini = ua.includes("miniprogram");
|
package/package.json
CHANGED