@vope/utils 1.6.0-bate.7 → 1.6.0
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/clamp.js +3 -23
- package/dist/classnames.js +7 -27
- package/dist/compare/version.js +3 -23
- package/dist/compare/weak-equal.js +5 -25
- package/dist/convert/json.js +3 -23
- package/dist/convert/object.js +3 -23
- package/dist/convert/strings.js +3 -23
- package/dist/desens.js +7 -27
- package/dist/encoding.js +3 -23
- package/dist/index.cjs.js +1265 -0
- package/dist/index.js +72 -102
- package/dist/input-regex.js +3 -23
- package/dist/is/class.js +3 -23
- package/dist/is/empty.js +4 -24
- package/dist/is/key.js +3 -23
- package/dist/is/null.js +3 -23
- package/dist/load/image.js +3 -23
- package/dist/memory/basic.js +5 -25
- package/dist/memory/list.js +5 -25
- package/dist/memory/power.js +7 -27
- package/dist/memory/simple.js +5 -25
- package/dist/neo4j-anchors.js +6 -26
- package/dist/neo4j.js +12 -32
- package/dist/once.js +3 -23
- package/dist/parse/num.js +5 -25
- package/dist/power/decon.js +3 -23
- package/dist/rotate/angle.js +4 -24
- package/dist/rotate/rad.js +3 -23
- package/dist/serialize/url-params.js +8 -28
- package/dist/style/css.js +7 -27
- package/dist/subscriber.js +5 -25
- package/dist/table/flex.js +3 -23
- package/dist/union.js +3 -23
- package/dist/url/join.js +3 -23
- package/dist/url/params.js +5 -25
- package/dist/wait.js +3 -23
- package/package.json +8 -8
- package/sub_storage/{offline.mjs → offline.cjs.js} +59 -27
- package/sub_storage/offline.js +15 -45
- package/sub_storage/package.json +2 -2
- package/dist/clamp.mjs +0 -11
- package/dist/classnames.mjs +0 -17
- package/dist/compare/version.mjs +0 -15
- package/dist/compare/weak-equal.mjs +0 -33
- package/dist/convert/json.mjs +0 -7
- package/dist/convert/object.mjs +0 -7
- package/dist/convert/strings.mjs +0 -7
- package/dist/desens.mjs +0 -51
- package/dist/encoding.mjs +0 -56
- package/dist/index.mjs +0 -73
- package/dist/input-regex.mjs +0 -8
- package/dist/is/class.mjs +0 -22
- package/dist/is/empty.mjs +0 -5
- package/dist/is/key.mjs +0 -4
- package/dist/is/null.mjs +0 -4
- package/dist/load/image.mjs +0 -11
- package/dist/memory/basic.mjs +0 -167
- package/dist/memory/list.mjs +0 -12
- package/dist/memory/power.mjs +0 -13
- package/dist/memory/simple.mjs +0 -94
- package/dist/neo4j-anchors.mjs +0 -169
- package/dist/neo4j.mjs +0 -161
- package/dist/once.mjs +0 -8
- package/dist/parse/num.mjs +0 -31
- package/dist/power/decon.mjs +0 -22
- package/dist/rotate/angle.mjs +0 -5
- package/dist/rotate/rad.mjs +0 -11
- package/dist/serialize/url-params.mjs +0 -53
- package/dist/style/css.mjs +0 -25
- package/dist/subscriber.mjs +0 -64
- package/dist/table/flex.mjs +0 -96
- package/dist/union.mjs +0 -47
- package/dist/url/join.mjs +0 -9
- package/dist/url/params.mjs +0 -8
- package/dist/wait.mjs +0 -4
|
@@ -1,17 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key2 of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
16
|
+
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/storage/offline.ts
|
|
31
|
+
var offline_exports = {};
|
|
32
|
+
__export(offline_exports, {
|
|
33
|
+
OfflineStorage: () => OfflineStorage
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(offline_exports);
|
|
36
|
+
var import_localforage = __toESM(require("localforage"));
|
|
37
|
+
var import_lodash_es = require("lodash-es");
|
|
38
|
+
var import_sm_crypto = require("sm-crypto");
|
|
39
|
+
var NAME = "@vope/utils";
|
|
40
|
+
var PREFIX = NAME + "_";
|
|
41
|
+
var key = [25, 144, 1, 32, 25, 135, 6, 40, 32, 23, 18, 19, 32, 36, 9, 5];
|
|
42
|
+
var iv = [182, 59, 9, 29, 86, 64, 118, 111, 112, 101, 47, 117, 116, 105, 108, 115];
|
|
43
|
+
var config = {
|
|
9
44
|
output: "string",
|
|
10
45
|
mode: "cbc",
|
|
11
46
|
iv
|
|
12
47
|
};
|
|
13
|
-
|
|
14
|
-
|
|
48
|
+
var HEADER = "." + import_sm_crypto.sm4.encrypt(NAME, key, config);
|
|
49
|
+
var encrypt = (data) => {
|
|
15
50
|
let text = "";
|
|
16
51
|
for (const key2 in data) {
|
|
17
52
|
const value = data[key2];
|
|
@@ -19,13 +54,13 @@ const encrypt = (data) => {
|
|
|
19
54
|
text && (text += "&");
|
|
20
55
|
text += key2 + ":" + value;
|
|
21
56
|
}
|
|
22
|
-
return sm4.encrypt(text, key, config);
|
|
57
|
+
return import_sm_crypto.sm4.encrypt(text, key, config);
|
|
23
58
|
};
|
|
24
|
-
|
|
59
|
+
var decrypt = (text) => {
|
|
25
60
|
const data = {};
|
|
26
61
|
let value;
|
|
27
62
|
try {
|
|
28
|
-
value = sm4.decrypt(text, key, config);
|
|
63
|
+
value = import_sm_crypto.sm4.decrypt(text, key, config);
|
|
29
64
|
} catch {
|
|
30
65
|
value = "";
|
|
31
66
|
}
|
|
@@ -39,21 +74,21 @@ const decrypt = (text) => {
|
|
|
39
74
|
});
|
|
40
75
|
return data;
|
|
41
76
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
77
|
+
var structKey = (index) => index.toString(16).padStart(8, "0");
|
|
78
|
+
var reductKey = (key2) => parseInt(key2, 16);
|
|
79
|
+
var MESSAGES = {
|
|
45
80
|
mount: "Please wait for the mounting to complete",
|
|
46
81
|
auth: "Unauthorized operation",
|
|
47
82
|
push: "Cannot add data to expired databases",
|
|
48
83
|
update: "Cannot update data to expired databases",
|
|
49
84
|
get: "Cannot get data from expired databases"
|
|
50
85
|
};
|
|
51
|
-
|
|
52
|
-
driver:
|
|
86
|
+
var createInstance = (name, version = 2) => import_localforage.default.createInstance({
|
|
87
|
+
driver: import_localforage.default.INDEXEDDB,
|
|
53
88
|
name,
|
|
54
89
|
version
|
|
55
90
|
});
|
|
56
|
-
|
|
91
|
+
var OfflineStorage = class _OfflineStorage {
|
|
57
92
|
#forage;
|
|
58
93
|
#expire;
|
|
59
94
|
#auth = false;
|
|
@@ -73,7 +108,7 @@ class OfflineStorage {
|
|
|
73
108
|
token: newToken,
|
|
74
109
|
crypto
|
|
75
110
|
}) {
|
|
76
|
-
const forage = this.#forage = createInstance(sm4.encrypt(PREFIX + name, key, config));
|
|
111
|
+
const forage = this.#forage = createInstance(import_sm_crypto.sm4.encrypt(PREFIX + name, key, config));
|
|
77
112
|
this.#mount = new Promise(async (resolve) => {
|
|
78
113
|
const keys = await forage.keys().then((keys2) => keys2).catch(() => []);
|
|
79
114
|
let size = 0;
|
|
@@ -175,13 +210,13 @@ class OfflineStorage {
|
|
|
175
210
|
if (e) throw e;
|
|
176
211
|
});
|
|
177
212
|
this.#size = 0;
|
|
178
|
-
await
|
|
213
|
+
await import_localforage.default.dropInstance({
|
|
179
214
|
name: this.#forage.config().name
|
|
180
215
|
});
|
|
181
216
|
}
|
|
182
217
|
static default(options) {
|
|
183
|
-
isString(options) && (options = { name: options });
|
|
184
|
-
return new
|
|
218
|
+
(0, import_lodash_es.isString)(options) && (options = { name: options });
|
|
219
|
+
return new _OfflineStorage({
|
|
185
220
|
...options,
|
|
186
221
|
crypto: {
|
|
187
222
|
encrypt(plain) {
|
|
@@ -201,7 +236,7 @@ class OfflineStorage {
|
|
|
201
236
|
if (name === void 0) continue;
|
|
202
237
|
let text;
|
|
203
238
|
try {
|
|
204
|
-
text = sm4.decrypt(name, key, config);
|
|
239
|
+
text = import_sm_crypto.sm4.decrypt(name, key, config);
|
|
205
240
|
} catch {
|
|
206
241
|
continue;
|
|
207
242
|
}
|
|
@@ -217,7 +252,4 @@ class OfflineStorage {
|
|
|
217
252
|
}
|
|
218
253
|
await Promise.all(tasks);
|
|
219
254
|
}
|
|
220
|
-
}
|
|
221
|
-
export {
|
|
222
|
-
OfflineStorage
|
|
223
255
|
};
|
package/sub_storage/offline.js
CHANGED
|
@@ -1,39 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key2 of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
16
|
-
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var offline_exports = {};
|
|
30
|
-
__export(offline_exports, {
|
|
31
|
-
OfflineStorage: () => OfflineStorage
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(offline_exports);
|
|
34
|
-
var import_localforage = __toESM(require("localforage"), 1);
|
|
35
|
-
var import_lodash_es = require("lodash-es");
|
|
36
|
-
var import_sm_crypto = require("sm-crypto");
|
|
1
|
+
import localforage from "localforage";
|
|
2
|
+
import { isString } from "lodash-es";
|
|
3
|
+
import { sm4 } from "sm-crypto";
|
|
37
4
|
const NAME = "@vope/utils";
|
|
38
5
|
const PREFIX = NAME + "_";
|
|
39
6
|
const key = [25, 144, 1, 32, 25, 135, 6, 40, 32, 23, 18, 19, 32, 36, 9, 5];
|
|
@@ -43,7 +10,7 @@ const config = {
|
|
|
43
10
|
mode: "cbc",
|
|
44
11
|
iv
|
|
45
12
|
};
|
|
46
|
-
const HEADER = "." +
|
|
13
|
+
const HEADER = "." + sm4.encrypt(NAME, key, config);
|
|
47
14
|
const encrypt = (data) => {
|
|
48
15
|
let text = "";
|
|
49
16
|
for (const key2 in data) {
|
|
@@ -52,13 +19,13 @@ const encrypt = (data) => {
|
|
|
52
19
|
text && (text += "&");
|
|
53
20
|
text += key2 + ":" + value;
|
|
54
21
|
}
|
|
55
|
-
return
|
|
22
|
+
return sm4.encrypt(text, key, config);
|
|
56
23
|
};
|
|
57
24
|
const decrypt = (text) => {
|
|
58
25
|
const data = {};
|
|
59
26
|
let value;
|
|
60
27
|
try {
|
|
61
|
-
value =
|
|
28
|
+
value = sm4.decrypt(text, key, config);
|
|
62
29
|
} catch {
|
|
63
30
|
value = "";
|
|
64
31
|
}
|
|
@@ -81,8 +48,8 @@ const MESSAGES = {
|
|
|
81
48
|
update: "Cannot update data to expired databases",
|
|
82
49
|
get: "Cannot get data from expired databases"
|
|
83
50
|
};
|
|
84
|
-
const createInstance = (name, version = 2) =>
|
|
85
|
-
driver:
|
|
51
|
+
const createInstance = (name, version = 2) => localforage.createInstance({
|
|
52
|
+
driver: localforage.INDEXEDDB,
|
|
86
53
|
name,
|
|
87
54
|
version
|
|
88
55
|
});
|
|
@@ -106,7 +73,7 @@ class OfflineStorage {
|
|
|
106
73
|
token: newToken,
|
|
107
74
|
crypto
|
|
108
75
|
}) {
|
|
109
|
-
const forage = this.#forage = createInstance(
|
|
76
|
+
const forage = this.#forage = createInstance(sm4.encrypt(PREFIX + name, key, config));
|
|
110
77
|
this.#mount = new Promise(async (resolve) => {
|
|
111
78
|
const keys = await forage.keys().then((keys2) => keys2).catch(() => []);
|
|
112
79
|
let size = 0;
|
|
@@ -208,12 +175,12 @@ class OfflineStorage {
|
|
|
208
175
|
if (e) throw e;
|
|
209
176
|
});
|
|
210
177
|
this.#size = 0;
|
|
211
|
-
await
|
|
178
|
+
await localforage.dropInstance({
|
|
212
179
|
name: this.#forage.config().name
|
|
213
180
|
});
|
|
214
181
|
}
|
|
215
182
|
static default(options) {
|
|
216
|
-
|
|
183
|
+
isString(options) && (options = { name: options });
|
|
217
184
|
return new OfflineStorage({
|
|
218
185
|
...options,
|
|
219
186
|
crypto: {
|
|
@@ -234,7 +201,7 @@ class OfflineStorage {
|
|
|
234
201
|
if (name === void 0) continue;
|
|
235
202
|
let text;
|
|
236
203
|
try {
|
|
237
|
-
text =
|
|
204
|
+
text = sm4.decrypt(name, key, config);
|
|
238
205
|
} catch {
|
|
239
206
|
continue;
|
|
240
207
|
}
|
|
@@ -251,3 +218,6 @@ class OfflineStorage {
|
|
|
251
218
|
await Promise.all(tasks);
|
|
252
219
|
}
|
|
253
220
|
}
|
|
221
|
+
export {
|
|
222
|
+
OfflineStorage
|
|
223
|
+
};
|
package/sub_storage/package.json
CHANGED
package/dist/clamp.mjs
DELETED
package/dist/classnames.mjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { isBoolean, isString } from "lodash-es";
|
|
2
|
-
const add = (a, b) => a ? a + " " + b : b;
|
|
3
|
-
const classnames = (...list) => list.reduce((caches, data) => {
|
|
4
|
-
if (isString(data)) {
|
|
5
|
-
data && (caches = add(caches, data));
|
|
6
|
-
} else if (Array.isArray(data)) {
|
|
7
|
-
data.forEach((value) => value && isString(value) && (caches = add(caches, value)));
|
|
8
|
-
} else if (!isBoolean(data)) {
|
|
9
|
-
for (const key in data) {
|
|
10
|
-
key && data[key] && (caches = add(caches, key));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return caches;
|
|
14
|
-
}, "");
|
|
15
|
-
export {
|
|
16
|
-
classnames
|
|
17
|
-
};
|
package/dist/compare/version.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const CHAR = ".";
|
|
2
|
-
const compareVersion = (from, to) => {
|
|
3
|
-
const froms = from.split(CHAR);
|
|
4
|
-
const tos = to.split(CHAR);
|
|
5
|
-
for (let i = 0, max = Math.max(froms.length, tos.length); i < max; i++) {
|
|
6
|
-
const fromV = +froms[i] || 0;
|
|
7
|
-
const toV = +tos[i] || 0;
|
|
8
|
-
if (fromV > toV) return -1;
|
|
9
|
-
if (fromV < toV) return 1;
|
|
10
|
-
}
|
|
11
|
-
return 0;
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
compareVersion
|
|
15
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { hash8strings } from "../convert/strings";
|
|
2
|
-
const deepWeakEqual = (from, to, exclude) => {
|
|
3
|
-
if (typeof from !== "object" || from === null || typeof to !== "object" || to === null) return from === to;
|
|
4
|
-
if (Array.isArray(from) && Array.isArray(to)) {
|
|
5
|
-
if (from.length !== to.length) return false;
|
|
6
|
-
return !from.some((t1, index) => {
|
|
7
|
-
if (!deepWeakEqual(t1, to[index])) {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
} else {
|
|
12
|
-
const caches = {};
|
|
13
|
-
const excludeCaches = exclude && hash8strings(exclude);
|
|
14
|
-
for (const key in from) {
|
|
15
|
-
if (excludeCaches && key in excludeCaches) continue;
|
|
16
|
-
if (!deepWeakEqual(from[key], to[key])) {
|
|
17
|
-
return false;
|
|
18
|
-
} else {
|
|
19
|
-
caches[key] = key;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
for (const key in to) {
|
|
23
|
-
if (excludeCaches && key in excludeCaches || key in caches) continue;
|
|
24
|
-
if (!deepWeakEqual(from[key], to[key])) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return true;
|
|
30
|
-
};
|
|
31
|
-
export {
|
|
32
|
-
deepWeakEqual
|
|
33
|
-
};
|
package/dist/convert/json.mjs
DELETED
package/dist/convert/object.mjs
DELETED
package/dist/convert/strings.mjs
DELETED
package/dist/desens.mjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { isString } from "lodash-es";
|
|
2
|
-
const desensEncrypt = (plaintext, encrypt) => {
|
|
3
|
-
const rules = [];
|
|
4
|
-
let point = -1;
|
|
5
|
-
let ciphertext = encrypt(plaintext).reduce((cache, { range, ciphertext: ciphertext2 }) => {
|
|
6
|
-
cache += plaintext.slice(point + 1, range[0]) + ciphertext2;
|
|
7
|
-
point = range[1];
|
|
8
|
-
rules.push({
|
|
9
|
-
range,
|
|
10
|
-
modify: ciphertext2.length
|
|
11
|
-
});
|
|
12
|
-
return cache;
|
|
13
|
-
}, "");
|
|
14
|
-
if (point !== -1) {
|
|
15
|
-
ciphertext += plaintext.slice(point + 1);
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
ciphertext,
|
|
19
|
-
rules
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
const desensDecrypt = (ciphertext, rules, decrypt) => {
|
|
23
|
-
Array.isArray(rules) || (rules = [rules]);
|
|
24
|
-
let offset = 0;
|
|
25
|
-
let from = 0;
|
|
26
|
-
return rules.reduce((cache, { range: [start, stop], modify }) => {
|
|
27
|
-
cache += ciphertext.slice(from, start + offset) + decrypt(ciphertext.slice(start + offset, start + offset + modify));
|
|
28
|
-
from = start + offset + modify;
|
|
29
|
-
offset += modify - (stop + 1 - start);
|
|
30
|
-
return cache;
|
|
31
|
-
}, "") + ciphertext.slice(from);
|
|
32
|
-
};
|
|
33
|
-
const desensReplace = (ciphertext, rules, replacer = "*") => {
|
|
34
|
-
Array.isArray(rules) || (rules = [rules]);
|
|
35
|
-
let offset = 0;
|
|
36
|
-
let from = 0;
|
|
37
|
-
return rules.reduce((cache, { range: [start, stop], modify }) => {
|
|
38
|
-
const part = ciphertext.slice(start + offset, start + offset + modify);
|
|
39
|
-
const size = stop + 1 - start;
|
|
40
|
-
const replaceValue = isString(replacer) ? replacer.repeat(size) : replacer[Symbol.replace](part, size);
|
|
41
|
-
cache += ciphertext.slice(from, start + offset) + replaceValue;
|
|
42
|
-
from = start + offset + modify;
|
|
43
|
-
offset += modify - size;
|
|
44
|
-
return cache;
|
|
45
|
-
}, "") + ciphertext.slice(from);
|
|
46
|
-
};
|
|
47
|
-
export {
|
|
48
|
-
desensDecrypt,
|
|
49
|
-
desensEncrypt,
|
|
50
|
-
desensReplace
|
|
51
|
-
};
|
package/dist/encoding.mjs
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const utf8_first_prefix = /^1{2,}/g;
|
|
2
|
-
const utf8_other_prefix = /^10/;
|
|
3
|
-
const Encodes = {
|
|
4
|
-
UTF_8: "utf-8",
|
|
5
|
-
UTF_16LE: "utf-16le",
|
|
6
|
-
UTF_16BE: "utf-16be",
|
|
7
|
-
GBK: "gbk"
|
|
8
|
-
};
|
|
9
|
-
const BOM = {
|
|
10
|
-
UTF_8: [239, 187, 191],
|
|
11
|
-
UTF_16LE: [255, 254],
|
|
12
|
-
UTF_16BE: [254, 255]
|
|
13
|
-
};
|
|
14
|
-
const equal = (uint, list) => {
|
|
15
|
-
return uint.length === list.length ? !uint.some((value, index) => value !== list[index]) : false;
|
|
16
|
-
};
|
|
17
|
-
const getEncoding = (uint, limit = 1024) => {
|
|
18
|
-
let encoding;
|
|
19
|
-
let offset = 0;
|
|
20
|
-
for (const key in BOM) {
|
|
21
|
-
const head = BOM[key];
|
|
22
|
-
if (equal(uint.slice(0, head.length), head)) {
|
|
23
|
-
offset = head.length;
|
|
24
|
-
encoding = Encodes[key];
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (!encoding) {
|
|
29
|
-
let isBreak = false;
|
|
30
|
-
top:
|
|
31
|
-
for (let i = 0, max = Math.min(uint.length, limit); i < max; i++) {
|
|
32
|
-
const data = uint[i];
|
|
33
|
-
if (data < 128) continue;
|
|
34
|
-
const match = data.toString(2).match(utf8_first_prefix);
|
|
35
|
-
if (match) {
|
|
36
|
-
for (let m = 0; m < match[0].length - 1; m++) {
|
|
37
|
-
const target = uint[++i];
|
|
38
|
-
if (target == void 0 || !utf8_other_prefix.test(target.toString(2))) {
|
|
39
|
-
encoding = Encodes.GBK;
|
|
40
|
-
isBreak = true;
|
|
41
|
-
break top;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
} else {
|
|
45
|
-
encoding = Encodes.GBK;
|
|
46
|
-
isBreak = true;
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
isBreak || (encoding = Encodes.UTF_8);
|
|
51
|
-
}
|
|
52
|
-
return { encoding, offset };
|
|
53
|
-
};
|
|
54
|
-
export {
|
|
55
|
-
getEncoding
|
|
56
|
-
};
|
package/dist/index.mjs
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { clamp } from "./clamp";
|
|
2
|
-
import { classnames } from "./classnames";
|
|
3
|
-
import { compareVersion } from "./compare/version";
|
|
4
|
-
import { deepWeakEqual } from "./compare/weak-equal";
|
|
5
|
-
import { hash8json } from "./convert/json";
|
|
6
|
-
import { hash8object } from "./convert/object";
|
|
7
|
-
import { hash8strings } from "./convert/strings";
|
|
8
|
-
import { desensEncrypt, desensDecrypt, desensReplace } from "./desens";
|
|
9
|
-
import { getEncoding } from "./encoding";
|
|
10
|
-
import { inputRegex } from "./input-regex";
|
|
11
|
-
import { isClass } from "./is/class";
|
|
12
|
-
import { isEmpty } from "./is/empty";
|
|
13
|
-
import { isKey } from "./is/key";
|
|
14
|
-
import { isNull } from "./is/null";
|
|
15
|
-
import { loadImage } from "./load/image";
|
|
16
|
-
import { MemoryBasic } from "./memory/basic";
|
|
17
|
-
import { MemoryList } from "./memory/list";
|
|
18
|
-
import { MemoryPower } from "./memory/power";
|
|
19
|
-
import { MemorySimple } from "./memory/simple";
|
|
20
|
-
import { default as default2 } from "./neo4j-anchors";
|
|
21
|
-
import { default as default3 } from "./neo4j";
|
|
22
|
-
import { once } from "./once";
|
|
23
|
-
import { parseNum } from "./parse/num";
|
|
24
|
-
import { deconPowersSum } from "./power/decon";
|
|
25
|
-
import { rotateAngle } from "./rotate/angle";
|
|
26
|
-
import { rotateRad } from "./rotate/rad";
|
|
27
|
-
import { cubeURLParams, flatURLParams } from "./serialize/url-params";
|
|
28
|
-
import { css } from "./style/css";
|
|
29
|
-
import { default as default4 } from "./subscriber";
|
|
30
|
-
import { FlexTable } from "./table/flex";
|
|
31
|
-
import { Union } from "./union";
|
|
32
|
-
import { joinPaths } from "./url/join";
|
|
33
|
-
import { connectURLParams } from "./url/params";
|
|
34
|
-
import { wait } from "./wait";
|
|
35
|
-
export {
|
|
36
|
-
FlexTable,
|
|
37
|
-
MemoryBasic,
|
|
38
|
-
MemoryList,
|
|
39
|
-
MemoryPower,
|
|
40
|
-
MemorySimple,
|
|
41
|
-
default3 as Neo4j,
|
|
42
|
-
default2 as Neo4jAhchors,
|
|
43
|
-
default4 as Subscriber,
|
|
44
|
-
Union,
|
|
45
|
-
clamp,
|
|
46
|
-
classnames,
|
|
47
|
-
compareVersion,
|
|
48
|
-
connectURLParams,
|
|
49
|
-
css,
|
|
50
|
-
cubeURLParams,
|
|
51
|
-
deconPowersSum,
|
|
52
|
-
deepWeakEqual,
|
|
53
|
-
desensDecrypt,
|
|
54
|
-
desensEncrypt,
|
|
55
|
-
desensReplace,
|
|
56
|
-
flatURLParams,
|
|
57
|
-
getEncoding,
|
|
58
|
-
hash8json,
|
|
59
|
-
hash8object,
|
|
60
|
-
hash8strings,
|
|
61
|
-
inputRegex,
|
|
62
|
-
isClass,
|
|
63
|
-
isEmpty,
|
|
64
|
-
isKey,
|
|
65
|
-
isNull,
|
|
66
|
-
joinPaths,
|
|
67
|
-
loadImage,
|
|
68
|
-
once,
|
|
69
|
-
parseNum,
|
|
70
|
-
rotateAngle,
|
|
71
|
-
rotateRad,
|
|
72
|
-
wait
|
|
73
|
-
};
|
package/dist/input-regex.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const RE_REGEX = /[$()*+.[?\\^{|]/g;
|
|
2
|
-
const RE_STRING = /[$()*+.[?\\^{|-]/g;
|
|
3
|
-
function inputRegex(text, flags) {
|
|
4
|
-
return flags === false ? text.replace(RE_STRING, ($0) => "\\" + $0) : new RegExp(text.replace(RE_REGEX, ($0) => "\\" + $0), flags);
|
|
5
|
-
}
|
|
6
|
-
export {
|
|
7
|
-
inputRegex
|
|
8
|
-
};
|
package/dist/is/class.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const re_anonymous = /^function\s+\(|^function\s+anonymous\(/;
|
|
2
|
-
const re_function = /^function\s+[A-Z]/;
|
|
3
|
-
const re_this = /\b\(this\b|\bthis[\.\[]\b/;
|
|
4
|
-
const re_check = /classCallCheck\(this/;
|
|
5
|
-
const re_default = /^function\sdefault_\d+\s*\(/;
|
|
6
|
-
const isClass = (value, strict = true) => {
|
|
7
|
-
if (typeof value !== "function") return false;
|
|
8
|
-
const proto = value.prototype;
|
|
9
|
-
if (!proto || proto.constructor !== value) return false;
|
|
10
|
-
const str = value.toString();
|
|
11
|
-
if (str.slice(0, 5) === "class" || Object.getOwnPropertyNames(proto).length >= 2) return true;
|
|
12
|
-
if (re_anonymous.test(str)) return false;
|
|
13
|
-
if (strict && re_function.test(str)) return true;
|
|
14
|
-
if (re_this.test(str)) {
|
|
15
|
-
if (!strict || re_check.test(str)) return true;
|
|
16
|
-
return re_default.test(str);
|
|
17
|
-
}
|
|
18
|
-
return false;
|
|
19
|
-
};
|
|
20
|
-
export {
|
|
21
|
-
isClass
|
|
22
|
-
};
|
package/dist/is/empty.mjs
DELETED
package/dist/is/key.mjs
DELETED
package/dist/is/null.mjs
DELETED