@daysnap/utils 0.0.55 → 0.0.57
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/modules.md +268 -84
- package/es/filterIdCard.d.ts +1 -0
- package/es/filterIdCard.js +1 -0
- package/es/formatDateStr.d.ts +1 -0
- package/es/formatDateStr.js +1 -0
- package/es/getRandom.d.ts +6 -0
- package/es/getRandom.js +11 -0
- package/es/getRandomNumber.d.ts +5 -0
- package/es/getRandomNumber.js +8 -0
- package/es/index.d.ts +8 -1
- package/es/index.js +8 -1
- package/es/isEmptyObject.d.ts +2 -2
- package/es/isEmptyObject.js +3 -3
- package/es/isIE.d.ts +6 -0
- package/es/isIE.js +27 -0
- package/es/isWeChat.d.ts +9 -0
- package/es/isWeChat.js +13 -0
- package/es/isWeChatMiniProgram.d.ts +5 -0
- package/es/isWeChatMiniProgram.js +8 -0
- package/es/parseQuery.js +8 -2
- package/es/scrollToTop.d.ts +4 -0
- package/es/scrollToTop.js +10 -0
- package/es/stringifyQuery.d.ts +1 -1
- package/es/stringifyQuery.js +1 -1
- package/es/toCDB.d.ts +4 -0
- package/es/toCDB.js +19 -0
- package/es/toDBC.d.ts +4 -0
- package/es/toDBC.js +19 -0
- package/lib/filterIdCard.d.ts +1 -0
- package/lib/filterIdCard.js +1 -0
- package/lib/formatDateStr.d.ts +1 -0
- package/lib/formatDateStr.js +1 -0
- package/lib/getRandom.d.ts +6 -0
- package/lib/getRandom.js +15 -0
- package/lib/getRandomNumber.d.ts +5 -0
- package/lib/getRandomNumber.js +12 -0
- package/lib/index.d.ts +8 -1
- package/lib/index.js +8 -1
- package/lib/isEmptyObject.d.ts +2 -2
- package/lib/isEmptyObject.js +3 -3
- package/lib/isIE.d.ts +6 -0
- package/lib/isIE.js +31 -0
- package/lib/isWeChat.d.ts +9 -0
- package/lib/isWeChat.js +18 -0
- package/lib/isWeChatMiniProgram.d.ts +5 -0
- package/lib/isWeChatMiniProgram.js +12 -0
- package/lib/parseQuery.js +8 -2
- package/lib/scrollToTop.d.ts +4 -0
- package/lib/scrollToTop.js +14 -0
- package/lib/stringifyQuery.d.ts +1 -1
- package/lib/stringifyQuery.js +1 -1
- package/lib/toCDB.d.ts +4 -0
- package/lib/toCDB.js +23 -0
- package/lib/toDBC.d.ts +4 -0
- package/lib/toDBC.js +23 -0
- package/package.json +1 -1
- package/es/isWeixin.d.ts +0 -4
- package/es/isWeixin.js +0 -6
- package/lib/isWeixin.d.ts +0 -4
- package/lib/isWeixin.js +0 -10
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scrollToTop = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 滚动到页面顶部
|
|
6
|
+
*/
|
|
7
|
+
function scrollToTop() {
|
|
8
|
+
const height = document.documentElement.scrollTop || document.body.scrollTop;
|
|
9
|
+
if (height > 0) {
|
|
10
|
+
window.requestAnimationFrame(scrollToTop);
|
|
11
|
+
window.scrollTo(0, height - height / 8);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.scrollToTop = scrollToTop;
|
package/lib/stringifyQuery.d.ts
CHANGED
package/lib/stringifyQuery.js
CHANGED
package/lib/toCDB.d.ts
ADDED
package/lib/toCDB.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toCDB = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 全角转换为半角
|
|
6
|
+
*/
|
|
7
|
+
function toCDB(str) {
|
|
8
|
+
let result = '';
|
|
9
|
+
for (let i = 0; i < str.length; i++) {
|
|
10
|
+
const code = str.charCodeAt(i);
|
|
11
|
+
if (code >= 65281 && code <= 65374) {
|
|
12
|
+
result += String.fromCharCode(str.charCodeAt(i) - 65248);
|
|
13
|
+
}
|
|
14
|
+
else if (code == 12288) {
|
|
15
|
+
result += String.fromCharCode(str.charCodeAt(i) - 12288 + 32);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
result += str.charAt(i);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
exports.toCDB = toCDB;
|
package/lib/toDBC.d.ts
ADDED
package/lib/toDBC.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toDBC = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 半角转换为全角
|
|
6
|
+
*/
|
|
7
|
+
function toDBC(str) {
|
|
8
|
+
let result = '';
|
|
9
|
+
for (let i = 0; i < str.length; i++) {
|
|
10
|
+
const code = str.charCodeAt(i);
|
|
11
|
+
if (code >= 33 && code <= 126) {
|
|
12
|
+
result += String.fromCharCode(str.charCodeAt(i) + 65248);
|
|
13
|
+
}
|
|
14
|
+
else if (code == 32) {
|
|
15
|
+
result += String.fromCharCode(str.charCodeAt(i) + 12288 - 32);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
result += str.charAt(i);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
exports.toDBC = toDBC;
|
package/package.json
CHANGED
package/es/isWeixin.d.ts
DELETED
package/es/isWeixin.js
DELETED
package/lib/isWeixin.d.ts
DELETED
package/lib/isWeixin.js
DELETED