@vope/utils 1.4.0 → 1.4.1
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/cjs/clamp.js +29 -12
- package/cjs/classnames.js +34 -20
- package/cjs/compare/version.js +35 -18
- package/cjs/compare/weak-equal.js +49 -36
- package/cjs/convert/json.js +25 -15
- package/cjs/convert/object.js +26 -16
- package/cjs/convert/strings.js +25 -9
- package/cjs/encoding.js +64 -51
- package/cjs/index.js +76 -50
- package/cjs/input-regex.js +24 -5
- package/cjs/is/class.js +40 -23
- package/cjs/is/empty.js +34 -10
- package/cjs/is/null.js +24 -7
- package/cjs/memory/basic.js +159 -139
- package/cjs/memory/list.js +39 -17
- package/cjs/memory/power.js +40 -16
- package/cjs/memory/type.d.js +16 -0
- package/cjs/once.js +26 -13
- package/cjs/power/decon.js +38 -26
- package/cjs/rotate/angle.js +34 -12
- package/cjs/rotate/rad.js +29 -14
- package/cjs/union.js +41 -26
- package/cjs/url/join.js +27 -11
- package/cjs/url/params.js +41 -33
- package/cjs/wait.js +23 -5
- package/package.json +5 -5
package/cjs/clamp.js
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var clamp_exports = {};
|
|
20
|
+
__export(clamp_exports, {
|
|
21
|
+
default: () => clamp_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(clamp_exports);
|
|
24
|
+
var clamp_default = (value, min, max) => {
|
|
25
|
+
if (min > max) {
|
|
26
|
+
const swap = max;
|
|
27
|
+
max = min;
|
|
28
|
+
min = swap;
|
|
29
|
+
}
|
|
30
|
+
return Math.min(max, Math.max(min, value));
|
|
14
31
|
};
|
package/cjs/classnames.js
CHANGED
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var classnames_exports = {};
|
|
20
|
+
__export(classnames_exports, {
|
|
21
|
+
default: () => classnames_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(classnames_exports);
|
|
24
|
+
const add = (a, b) => a ? a + " " + b : b;
|
|
25
|
+
var classnames_default = (...list) => list.reduce((caches, data) => {
|
|
26
|
+
if (typeof data === "string") {
|
|
27
|
+
data && (caches = add(caches, data));
|
|
28
|
+
} else if (Array.isArray(data)) {
|
|
29
|
+
data.forEach((value) => value && (caches = add(caches, value)));
|
|
30
|
+
} else if (data) {
|
|
31
|
+
for (const key in data) {
|
|
32
|
+
key && data[key] && (caches = add(caches, key));
|
|
12
33
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
else if (data) {
|
|
17
|
-
for (const key in data) {
|
|
18
|
-
key && data[key] && (caches = add(caches, key));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return caches;
|
|
22
|
-
}, '');
|
|
34
|
+
}
|
|
35
|
+
return caches;
|
|
36
|
+
}, "");
|
package/cjs/compare/version.js
CHANGED
|
@@ -1,21 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var version_exports = {};
|
|
20
|
+
__export(version_exports, {
|
|
21
|
+
default: () => version_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(version_exports);
|
|
24
|
+
const CHAR = ".";
|
|
8
25
|
const compareVersion = (from, to) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
const froms = from.split(CHAR);
|
|
27
|
+
const tos = to.split(CHAR);
|
|
28
|
+
for (let i = 0, max = Math.max(froms.length, tos.length); i < max; i++) {
|
|
29
|
+
const fromV = +froms[i] || 0;
|
|
30
|
+
const toV = +tos[i] || 0;
|
|
31
|
+
if (fromV > toV)
|
|
32
|
+
return -1;
|
|
33
|
+
if (fromV < toV)
|
|
34
|
+
return 1;
|
|
35
|
+
}
|
|
36
|
+
return 0;
|
|
20
37
|
};
|
|
21
|
-
|
|
38
|
+
var version_default = compareVersion;
|
|
@@ -1,41 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var weak_equal_exports = {};
|
|
20
|
+
__export(weak_equal_exports, {
|
|
21
|
+
default: () => weak_equal_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(weak_equal_exports);
|
|
6
24
|
const deepWeakEqual = (from, to) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
if (typeof from !== "object" || from === null || typeof to !== "object" || to === null)
|
|
26
|
+
return from === to;
|
|
27
|
+
if (Array.isArray(from) && Array.isArray(to)) {
|
|
28
|
+
if (from.length !== to.length)
|
|
29
|
+
return false;
|
|
30
|
+
return !from.some((t1, index) => {
|
|
31
|
+
if (!deepWeakEqual(t1, to[index])) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
const caches = {};
|
|
37
|
+
for (const key in from) {
|
|
38
|
+
if (!deepWeakEqual(from[key], to[key])) {
|
|
39
|
+
return false;
|
|
40
|
+
} else {
|
|
41
|
+
caches[key] = key;
|
|
42
|
+
}
|
|
20
43
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
else {
|
|
28
|
-
caches[key] = key;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
for (const key in to) {
|
|
32
|
-
if (key in caches)
|
|
33
|
-
continue;
|
|
34
|
-
if (!deepWeakEqual(from[key], to[key])) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
44
|
+
for (const key in to) {
|
|
45
|
+
if (key in caches)
|
|
46
|
+
continue;
|
|
47
|
+
if (!deepWeakEqual(from[key], to[key])) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
38
50
|
}
|
|
39
|
-
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
40
53
|
};
|
|
41
|
-
|
|
54
|
+
var weak_equal_default = deepWeakEqual;
|
package/cjs/convert/json.js
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var json_exports = {};
|
|
20
|
+
__export(json_exports, {
|
|
21
|
+
default: () => json_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(json_exports);
|
|
14
24
|
const hash8json = (list, key) => list.reduce((caches, data) => {
|
|
15
|
-
|
|
16
|
-
|
|
25
|
+
caches[data[key]] = data;
|
|
26
|
+
return caches;
|
|
17
27
|
}, {});
|
|
18
|
-
|
|
28
|
+
var json_default = hash8json;
|
package/cjs/convert/object.js
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var object_exports = {};
|
|
20
|
+
__export(object_exports, {
|
|
21
|
+
default: () => object_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(object_exports);
|
|
14
24
|
const hash8object = (list, key) => list.reduce((caches, data) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}, new Map());
|
|
18
|
-
|
|
25
|
+
caches.set(data[key], data);
|
|
26
|
+
return caches;
|
|
27
|
+
}, /* @__PURE__ */ new Map());
|
|
28
|
+
var object_default = hash8object;
|
package/cjs/convert/strings.js
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var strings_exports = {};
|
|
20
|
+
__export(strings_exports, {
|
|
21
|
+
default: () => strings_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(strings_exports);
|
|
8
24
|
const hash8strings = (list) => list.reduce((caches, data, index) => {
|
|
9
|
-
|
|
10
|
-
|
|
25
|
+
caches[data] = index;
|
|
26
|
+
return caches;
|
|
11
27
|
}, {});
|
|
12
|
-
|
|
28
|
+
var strings_default = hash8strings;
|
package/cjs/encoding.js
CHANGED
|
@@ -1,64 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var encoding_exports = {};
|
|
20
|
+
__export(encoding_exports, {
|
|
21
|
+
default: () => encoding_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(encoding_exports);
|
|
3
24
|
const utf8_first_prefix = /^1{2,}/g;
|
|
4
25
|
const utf8_other_prefix = /^10/;
|
|
5
26
|
const Encodes = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
27
|
+
UTF_8: "utf-8",
|
|
28
|
+
UTF_16LE: "utf-16le",
|
|
29
|
+
UTF_16BE: "utf-16be",
|
|
30
|
+
GBK: "gbk"
|
|
10
31
|
};
|
|
11
32
|
const defaults = {
|
|
12
|
-
|
|
33
|
+
utf8: [239, 187, 191]
|
|
13
34
|
};
|
|
14
35
|
const equal = (uint, list) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
36
|
+
if (uint.length !== list.length)
|
|
37
|
+
return false;
|
|
38
|
+
return !uint.some((value, index) => value !== list[index]);
|
|
18
39
|
};
|
|
19
|
-
/**
|
|
20
|
-
* 根据文件内容判断文件的编码
|
|
21
|
-
* @param uint 文件内容Uint8Array格式
|
|
22
|
-
* @param limit 用于约束GBK和utf_8的判定上限
|
|
23
|
-
*/
|
|
24
40
|
const getEncoding = (uint, limit = 1024) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
isBreak = true;
|
|
50
|
-
break top;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
encoding = Encodes.GBK;
|
|
56
|
-
isBreak = true;
|
|
57
|
-
break;
|
|
41
|
+
let encoding;
|
|
42
|
+
let offset = 0;
|
|
43
|
+
if (equal(uint.slice(0, 3), defaults.utf8)) {
|
|
44
|
+
offset = defaults.utf8.length;
|
|
45
|
+
encoding = Encodes.UTF_8;
|
|
46
|
+
} else if (equal(uint.slice(0, 2), [255, 254])) {
|
|
47
|
+
encoding = Encodes.UTF_16LE;
|
|
48
|
+
} else if (equal(uint.slice(0, 2), [254, 255])) {
|
|
49
|
+
encoding = Encodes.UTF_16BE;
|
|
50
|
+
} else {
|
|
51
|
+
let isBreak = false;
|
|
52
|
+
top:
|
|
53
|
+
for (let i = 0; i < Math.min(uint.length, limit); i++) {
|
|
54
|
+
const data = uint[i];
|
|
55
|
+
if (data < 128)
|
|
56
|
+
continue;
|
|
57
|
+
const match = data.toString(2).match(utf8_first_prefix);
|
|
58
|
+
if (match) {
|
|
59
|
+
for (let m = 0; m < match[0].length - 1; m++) {
|
|
60
|
+
const target = uint[++i];
|
|
61
|
+
if (target == void 0 || !utf8_other_prefix.test(target.toString(2))) {
|
|
62
|
+
encoding = Encodes.GBK;
|
|
63
|
+
isBreak = true;
|
|
64
|
+
break top;
|
|
58
65
|
}
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
encoding = Encodes.GBK;
|
|
69
|
+
isBreak = true;
|
|
70
|
+
break;
|
|
59
71
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
}
|
|
73
|
+
isBreak || (encoding = Encodes.UTF_8);
|
|
74
|
+
}
|
|
75
|
+
return { encoding, offset };
|
|
63
76
|
};
|
|
64
|
-
|
|
77
|
+
var encoding_default = getEncoding;
|