@daysnap/utils 0.0.87 → 0.0.89
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/docs/interfaces/StorageManager.md +4 -4
- package/docs/interfaces/Trap.md +5 -5
- package/docs/modules.md +200 -118
- package/es/decode.d.ts +2 -0
- package/es/decode.js +47 -0
- package/es/getScrollTop.d.ts +4 -0
- package/es/getScrollTop.js +9 -0
- package/es/index.d.ts +3 -0
- package/es/index.js +3 -0
- package/es/setScrollTop.d.ts +4 -0
- package/es/setScrollTop.js +9 -0
- package/lib/decode.d.ts +2 -0
- package/lib/decode.js +52 -0
- package/lib/getScrollTop.d.ts +4 -0
- package/lib/getScrollTop.js +13 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/setScrollTop.d.ts +4 -0
- package/lib/setScrollTop.js +13 -0
- package/package.json +1 -1
package/es/decode.d.ts
ADDED
package/es/decode.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// weapp jwt-decode
|
|
2
|
+
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
3
|
+
const b64re =
|
|
4
|
+
// eslint-disable-next-line no-useless-escape
|
|
5
|
+
/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
|
|
6
|
+
// btoa
|
|
7
|
+
export const btoa = function (string) {
|
|
8
|
+
string = String(string);
|
|
9
|
+
let bitmap, a, b, c, result = '', i = 0,
|
|
10
|
+
// eslint-disable-next-line prefer-const
|
|
11
|
+
rest = string.length % 3;
|
|
12
|
+
for (; i < string.length;) {
|
|
13
|
+
if ((a = string.charCodeAt(i++)) > 255 ||
|
|
14
|
+
(b = string.charCodeAt(i++)) > 255 ||
|
|
15
|
+
(c = string.charCodeAt(i++)) > 255)
|
|
16
|
+
throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");
|
|
17
|
+
bitmap = (a << 16) | (b << 8) | c;
|
|
18
|
+
result +=
|
|
19
|
+
b64.charAt((bitmap >> 18) & 63) +
|
|
20
|
+
b64.charAt((bitmap >> 12) & 63) +
|
|
21
|
+
b64.charAt((bitmap >> 6) & 63) +
|
|
22
|
+
b64.charAt(bitmap & 63);
|
|
23
|
+
}
|
|
24
|
+
return rest ? result.slice(0, rest - 3) + '==='.substring(rest) : result;
|
|
25
|
+
};
|
|
26
|
+
// atob
|
|
27
|
+
export const atob = function (string) {
|
|
28
|
+
string = String(string).replace(/[\t\n\f\r ]+/g, '');
|
|
29
|
+
if (!b64re.test(string))
|
|
30
|
+
throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
|
|
31
|
+
string += '=='.slice(2 - (string.length & 3));
|
|
32
|
+
let bitmap, result = '', r1, r2, i = 0;
|
|
33
|
+
for (; i < string.length;) {
|
|
34
|
+
bitmap =
|
|
35
|
+
(b64.indexOf(string.charAt(i++)) << 18) |
|
|
36
|
+
(b64.indexOf(string.charAt(i++)) << 12) |
|
|
37
|
+
((r1 = b64.indexOf(string.charAt(i++))) << 6) |
|
|
38
|
+
(r2 = b64.indexOf(string.charAt(i++)));
|
|
39
|
+
result +=
|
|
40
|
+
r1 === 64
|
|
41
|
+
? String.fromCharCode((bitmap >> 16) & 255)
|
|
42
|
+
: r2 === 64
|
|
43
|
+
? String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255)
|
|
44
|
+
: String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255, bitmap & 255);
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
};
|
package/es/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from './createHexColorByHash';
|
|
|
14
14
|
export * from './createLinearFunction';
|
|
15
15
|
export * from './createWithLoading';
|
|
16
16
|
export * from './debounce';
|
|
17
|
+
export * from './decode';
|
|
17
18
|
export * from './downloadFile';
|
|
18
19
|
export * from './each';
|
|
19
20
|
export * from './exitFullscreen';
|
|
@@ -37,6 +38,7 @@ export * from './getImageInfo';
|
|
|
37
38
|
export * from './getRandom';
|
|
38
39
|
export * from './getRandomColor';
|
|
39
40
|
export * from './getRandomNumber';
|
|
41
|
+
export * from './getScrollTop';
|
|
40
42
|
export * from './getVideoInfo';
|
|
41
43
|
export * from './inBrowser';
|
|
42
44
|
export * from './insertLink';
|
|
@@ -95,6 +97,7 @@ export * from './reserve';
|
|
|
95
97
|
export * from './rgbToHex';
|
|
96
98
|
export * from './round';
|
|
97
99
|
export * from './scrollToTop';
|
|
100
|
+
export * from './setScrollTop';
|
|
98
101
|
export * from './sleep';
|
|
99
102
|
export * from './splitArray';
|
|
100
103
|
export * from './storage';
|
package/es/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export * from './createHexColorByHash';
|
|
|
15
15
|
export * from './createLinearFunction';
|
|
16
16
|
export * from './createWithLoading';
|
|
17
17
|
export * from './debounce';
|
|
18
|
+
export * from './decode';
|
|
18
19
|
export * from './downloadFile';
|
|
19
20
|
export * from './each';
|
|
20
21
|
export * from './exitFullscreen';
|
|
@@ -38,6 +39,7 @@ export * from './getImageInfo';
|
|
|
38
39
|
export * from './getRandom';
|
|
39
40
|
export * from './getRandomColor';
|
|
40
41
|
export * from './getRandomNumber';
|
|
42
|
+
export * from './getScrollTop';
|
|
41
43
|
export * from './getVideoInfo';
|
|
42
44
|
export * from './inBrowser';
|
|
43
45
|
export * from './insertLink';
|
|
@@ -96,6 +98,7 @@ export * from './reserve';
|
|
|
96
98
|
export * from './rgbToHex';
|
|
97
99
|
export * from './round';
|
|
98
100
|
export * from './scrollToTop';
|
|
101
|
+
export * from './setScrollTop';
|
|
99
102
|
export * from './sleep';
|
|
100
103
|
export * from './splitArray';
|
|
101
104
|
export * from './storage';
|
package/lib/decode.d.ts
ADDED
package/lib/decode.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.atob = exports.btoa = void 0;
|
|
4
|
+
// weapp jwt-decode
|
|
5
|
+
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
6
|
+
const b64re =
|
|
7
|
+
// eslint-disable-next-line no-useless-escape
|
|
8
|
+
/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
|
|
9
|
+
// btoa
|
|
10
|
+
const btoa = function (string) {
|
|
11
|
+
string = String(string);
|
|
12
|
+
let bitmap, a, b, c, result = '', i = 0,
|
|
13
|
+
// eslint-disable-next-line prefer-const
|
|
14
|
+
rest = string.length % 3;
|
|
15
|
+
for (; i < string.length;) {
|
|
16
|
+
if ((a = string.charCodeAt(i++)) > 255 ||
|
|
17
|
+
(b = string.charCodeAt(i++)) > 255 ||
|
|
18
|
+
(c = string.charCodeAt(i++)) > 255)
|
|
19
|
+
throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");
|
|
20
|
+
bitmap = (a << 16) | (b << 8) | c;
|
|
21
|
+
result +=
|
|
22
|
+
b64.charAt((bitmap >> 18) & 63) +
|
|
23
|
+
b64.charAt((bitmap >> 12) & 63) +
|
|
24
|
+
b64.charAt((bitmap >> 6) & 63) +
|
|
25
|
+
b64.charAt(bitmap & 63);
|
|
26
|
+
}
|
|
27
|
+
return rest ? result.slice(0, rest - 3) + '==='.substring(rest) : result;
|
|
28
|
+
};
|
|
29
|
+
exports.btoa = btoa;
|
|
30
|
+
// atob
|
|
31
|
+
const atob = function (string) {
|
|
32
|
+
string = String(string).replace(/[\t\n\f\r ]+/g, '');
|
|
33
|
+
if (!b64re.test(string))
|
|
34
|
+
throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
|
|
35
|
+
string += '=='.slice(2 - (string.length & 3));
|
|
36
|
+
let bitmap, result = '', r1, r2, i = 0;
|
|
37
|
+
for (; i < string.length;) {
|
|
38
|
+
bitmap =
|
|
39
|
+
(b64.indexOf(string.charAt(i++)) << 18) |
|
|
40
|
+
(b64.indexOf(string.charAt(i++)) << 12) |
|
|
41
|
+
((r1 = b64.indexOf(string.charAt(i++))) << 6) |
|
|
42
|
+
(r2 = b64.indexOf(string.charAt(i++)));
|
|
43
|
+
result +=
|
|
44
|
+
r1 === 64
|
|
45
|
+
? String.fromCharCode((bitmap >> 16) & 255)
|
|
46
|
+
: r2 === 64
|
|
47
|
+
? String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255)
|
|
48
|
+
: String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255, bitmap & 255);
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
exports.atob = atob;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getScrollTop = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 获取 scrollTop
|
|
6
|
+
*/
|
|
7
|
+
function getScrollTop() {
|
|
8
|
+
return (document.documentElement.scrollTop ||
|
|
9
|
+
window.pageYOffset ||
|
|
10
|
+
document.body.scrollTop ||
|
|
11
|
+
0);
|
|
12
|
+
}
|
|
13
|
+
exports.getScrollTop = getScrollTop;
|
package/lib/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from './createHexColorByHash';
|
|
|
14
14
|
export * from './createLinearFunction';
|
|
15
15
|
export * from './createWithLoading';
|
|
16
16
|
export * from './debounce';
|
|
17
|
+
export * from './decode';
|
|
17
18
|
export * from './downloadFile';
|
|
18
19
|
export * from './each';
|
|
19
20
|
export * from './exitFullscreen';
|
|
@@ -37,6 +38,7 @@ export * from './getImageInfo';
|
|
|
37
38
|
export * from './getRandom';
|
|
38
39
|
export * from './getRandomColor';
|
|
39
40
|
export * from './getRandomNumber';
|
|
41
|
+
export * from './getScrollTop';
|
|
40
42
|
export * from './getVideoInfo';
|
|
41
43
|
export * from './inBrowser';
|
|
42
44
|
export * from './insertLink';
|
|
@@ -95,6 +97,7 @@ export * from './reserve';
|
|
|
95
97
|
export * from './rgbToHex';
|
|
96
98
|
export * from './round';
|
|
97
99
|
export * from './scrollToTop';
|
|
100
|
+
export * from './setScrollTop';
|
|
98
101
|
export * from './sleep';
|
|
99
102
|
export * from './splitArray';
|
|
100
103
|
export * from './storage';
|
package/lib/index.js
CHANGED
|
@@ -31,6 +31,7 @@ __exportStar(require("./createHexColorByHash"), exports);
|
|
|
31
31
|
__exportStar(require("./createLinearFunction"), exports);
|
|
32
32
|
__exportStar(require("./createWithLoading"), exports);
|
|
33
33
|
__exportStar(require("./debounce"), exports);
|
|
34
|
+
__exportStar(require("./decode"), exports);
|
|
34
35
|
__exportStar(require("./downloadFile"), exports);
|
|
35
36
|
__exportStar(require("./each"), exports);
|
|
36
37
|
__exportStar(require("./exitFullscreen"), exports);
|
|
@@ -54,6 +55,7 @@ __exportStar(require("./getImageInfo"), exports);
|
|
|
54
55
|
__exportStar(require("./getRandom"), exports);
|
|
55
56
|
__exportStar(require("./getRandomColor"), exports);
|
|
56
57
|
__exportStar(require("./getRandomNumber"), exports);
|
|
58
|
+
__exportStar(require("./getScrollTop"), exports);
|
|
57
59
|
__exportStar(require("./getVideoInfo"), exports);
|
|
58
60
|
__exportStar(require("./inBrowser"), exports);
|
|
59
61
|
__exportStar(require("./insertLink"), exports);
|
|
@@ -112,6 +114,7 @@ __exportStar(require("./reserve"), exports);
|
|
|
112
114
|
__exportStar(require("./rgbToHex"), exports);
|
|
113
115
|
__exportStar(require("./round"), exports);
|
|
114
116
|
__exportStar(require("./scrollToTop"), exports);
|
|
117
|
+
__exportStar(require("./setScrollTop"), exports);
|
|
115
118
|
__exportStar(require("./sleep"), exports);
|
|
116
119
|
__exportStar(require("./splitArray"), exports);
|
|
117
120
|
__exportStar(require("./storage"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setScrollTop = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 设置 scrollTop
|
|
6
|
+
*/
|
|
7
|
+
function setScrollTop(scrollTop = 0) {
|
|
8
|
+
document.documentElement.scrollTop =
|
|
9
|
+
window.pageYOffset =
|
|
10
|
+
document.body.scrollTop =
|
|
11
|
+
scrollTop;
|
|
12
|
+
}
|
|
13
|
+
exports.setScrollTop = setScrollTop;
|