diginext-utils 2.1.8 → 2.1.9
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/README.md +162 -162
- package/package.json +1 -1
- package/src/Checker.ts +29 -29
- package/src/EventDispatcher.ts +62 -62
- package/src/FileUpload.ts +66 -66
- package/src/Slug.ts +365 -365
- package/src/Timer.ts +7 -7
- package/src/Validation.ts +36 -36
- package/src/array.ts +285 -285
- package/src/color.ts +87 -87
- package/src/console/enableConsole.ts +8 -8
- package/src/console/index.ts +17 -17
- package/src/console/log.ts +39 -39
- package/src/device/browser.ts +29 -29
- package/src/device/camera.ts +207 -207
- package/src/device/index.ts +230 -230
- package/src/device/os.ts +29 -29
- package/src/file/createDir.ts +14 -14
- package/src/file/fileMove.ts +32 -32
- package/src/file/findFilesByExt.ts +46 -46
- package/src/file/index.ts +7 -7
- package/src/images/index.ts +3 -3
- package/src/images/loadImage.ts +16 -16
- package/src/images/resize.ts +35 -35
- package/src/images/upload.ts +24 -24
- package/src/index.ts +39 -39
- package/src/json.ts +29 -29
- package/src/math/diffDate.ts +10 -10
- package/src/math/index.ts +90 -90
- package/src/math/positiveNumber.ts +12 -12
- package/src/name/en.ts +27 -27
- package/src/name/index.ts +8 -8
- package/src/name/vi.ts +23 -23
- package/src/object.ts +72 -72
- package/src/permission/index.ts +6 -6
- package/src/permission/requestCamera.ts +43 -43
- package/src/permission/requestDeviceOrientationControl.ts +33 -33
- package/src/response/index.ts +45 -45
- package/src/string/formatNumber.ts +12 -12
- package/src/string/generatePassword.ts +18 -18
- package/src/string/generateUUID.ts +37 -37
- package/src/string/getTextBetweenCharByIndex.ts +20 -20
- package/src/string/indexesOf.ts +15 -15
- package/src/string/makeDaySlug.ts +40 -40
- package/src/string/random.ts +33 -33
- package/src/string/trimNull.ts +16 -16
package/src/color.ts
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
export const random = (hex = false) => {
|
|
2
|
-
return (hex ? "#" : "") + Math.floor(Math.random() * 16777215).toString(16);
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
// This function (pSBC) will take a HEX or RGB web color.
|
|
6
|
-
// pSBC can shade it darker or lighter, or blend it with a second color, and can also pass it right thru but convert from Hex to RGB (Hex2RGB) or RGB to Hex (RGB2Hex).
|
|
7
|
-
// All without you even knowing what color format you are using.
|
|
8
|
-
// Version 4.0 (pref: https://github.com/PimpTrizkit/PJs/wiki/12.-Shade,-Blend-and-Convert-a-Web-Color-(pSBC.js));
|
|
9
|
-
|
|
10
|
-
export const pSBC = (p: any, c0: any, c1?: any, l?: any) => {
|
|
11
|
-
let r,
|
|
12
|
-
g,
|
|
13
|
-
b,
|
|
14
|
-
P,
|
|
15
|
-
f,
|
|
16
|
-
t,
|
|
17
|
-
h,
|
|
18
|
-
i = parseInt,
|
|
19
|
-
m = Math.round,
|
|
20
|
-
a: any = typeof c1 == "string";
|
|
21
|
-
if (typeof p != "number" || p < -1 || p > 1 || typeof c0 != "string" || (c0[0] != "r" && c0[0] != "#") || (c1 && !a)) return null;
|
|
22
|
-
|
|
23
|
-
const pSBCr = (d: any) => {
|
|
24
|
-
let n = d.length,
|
|
25
|
-
x: { r: number; g: number; b: number; a: number } = { r: 0, g: 0, b: 0, a: 1 };
|
|
26
|
-
if (n > 9) {
|
|
27
|
-
([r, g, b, a] = d = d.split(",")), (n = d.length);
|
|
28
|
-
if (n < 3 || n > 4) return null;
|
|
29
|
-
(x.r = i(r[3] == "a" ? r.slice(5) : r.slice(4))), (x.g = i(g)), (x.b = i(b)), (x.a = a ? parseFloat(a.toString()) : -1);
|
|
30
|
-
} else {
|
|
31
|
-
if (n == 8 || n == 6 || n < 4) return null;
|
|
32
|
-
if (n < 6) d = "#" + d[1] + d[1] + d[2] + d[2] + d[3] + d[3] + (n > 4 ? d[4] + d[4] : "");
|
|
33
|
-
d = i(d.slice(1), 16);
|
|
34
|
-
if (n == 9 || n == 5) (x.r = (d >> 24) & 255), (x.g = (d >> 16) & 255), (x.b = (d >> 8) & 255), (x.a = m((d & 255) / 0.255) / 1000);
|
|
35
|
-
else (x.r = d >> 16), (x.g = (d >> 8) & 255), (x.b = d & 255), (x.a = -1);
|
|
36
|
-
}
|
|
37
|
-
return x;
|
|
38
|
-
};
|
|
39
|
-
(h = c0.length > 9),
|
|
40
|
-
(h = a ? (c1.length > 9 ? true : c1 == "c" ? !h : false) : h),
|
|
41
|
-
(f = pSBCr(c0)),
|
|
42
|
-
(P = p < 0),
|
|
43
|
-
(t = c1 && c1 != "c" ? pSBCr(c1) : P ? { r: 0, g: 0, b: 0, a: -1 } : { r: 255, g: 255, b: 255, a: -1 }),
|
|
44
|
-
(p = P ? p * -1 : p),
|
|
45
|
-
(P = 1 - p);
|
|
46
|
-
if (!f || !t || typeof f == "undefined") return null;
|
|
47
|
-
else if (l) (r = m(P * f.r + p * t.r)), (g = m(P * f.g + p * t.g)), (b = m(P * f.b + p * t.b));
|
|
48
|
-
else (r = m((P * f.r ** 2 + p * t.r ** 2) ** 0.5)), (g = m((P * f.g ** 2 + p * t.g ** 2) ** 0.5)), (b = m((P * f.b ** 2 + p * t.b ** 2) ** 0.5));
|
|
49
|
-
|
|
50
|
-
(a = f.a), (t = t.a), (f = a >= 0 || t >= 0), (a = f ? (a < 0 ? t : t < 0 ? a : a * P + t * p) : 0);
|
|
51
|
-
|
|
52
|
-
if (h) return "rgb" + (f ? "a(" : "(") + r + "," + g + "," + b + (f ? "," + m(a * 1000) / 1000 : "") + ")";
|
|
53
|
-
else return "#" + (4294967296 + r * 16777216 + g * 65536 + b * 256 + (f ? m(a * 255) : 0)).toString(16).slice(1, f ? undefined : -2);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const hexToRgb = (hex: string) => {
|
|
57
|
-
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
58
|
-
return result
|
|
59
|
-
? {
|
|
60
|
-
r: parseInt(result[1], 16),
|
|
61
|
-
g: parseInt(result[2], 16),
|
|
62
|
-
b: parseInt(result[3], 16),
|
|
63
|
-
}
|
|
64
|
-
: null;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const hexDarken = (hex: string, amount: number) => {
|
|
68
|
-
return pSBC(-amount, hex);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const hexLighten = (hex: string, amount: number) => {
|
|
72
|
-
return pSBC(amount, hex);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const RGBToHex = (rgb: string | any) => {
|
|
76
|
-
return pSBC(0, rgb, "c", true);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const color = {
|
|
80
|
-
random,
|
|
81
|
-
pSBC,
|
|
82
|
-
hexToRgb,
|
|
83
|
-
hexDarken,
|
|
84
|
-
hexLighten,
|
|
85
|
-
RGBToHex,
|
|
86
|
-
};
|
|
87
|
-
export default color;
|
|
1
|
+
export const random = (hex = false) => {
|
|
2
|
+
return (hex ? "#" : "") + Math.floor(Math.random() * 16777215).toString(16);
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
// This function (pSBC) will take a HEX or RGB web color.
|
|
6
|
+
// pSBC can shade it darker or lighter, or blend it with a second color, and can also pass it right thru but convert from Hex to RGB (Hex2RGB) or RGB to Hex (RGB2Hex).
|
|
7
|
+
// All without you even knowing what color format you are using.
|
|
8
|
+
// Version 4.0 (pref: https://github.com/PimpTrizkit/PJs/wiki/12.-Shade,-Blend-and-Convert-a-Web-Color-(pSBC.js));
|
|
9
|
+
|
|
10
|
+
export const pSBC = (p: any, c0: any, c1?: any, l?: any) => {
|
|
11
|
+
let r,
|
|
12
|
+
g,
|
|
13
|
+
b,
|
|
14
|
+
P,
|
|
15
|
+
f,
|
|
16
|
+
t,
|
|
17
|
+
h,
|
|
18
|
+
i = parseInt,
|
|
19
|
+
m = Math.round,
|
|
20
|
+
a: any = typeof c1 == "string";
|
|
21
|
+
if (typeof p != "number" || p < -1 || p > 1 || typeof c0 != "string" || (c0[0] != "r" && c0[0] != "#") || (c1 && !a)) return null;
|
|
22
|
+
|
|
23
|
+
const pSBCr = (d: any) => {
|
|
24
|
+
let n = d.length,
|
|
25
|
+
x: { r: number; g: number; b: number; a: number } = { r: 0, g: 0, b: 0, a: 1 };
|
|
26
|
+
if (n > 9) {
|
|
27
|
+
([r, g, b, a] = d = d.split(",")), (n = d.length);
|
|
28
|
+
if (n < 3 || n > 4) return null;
|
|
29
|
+
(x.r = i(r[3] == "a" ? r.slice(5) : r.slice(4))), (x.g = i(g)), (x.b = i(b)), (x.a = a ? parseFloat(a.toString()) : -1);
|
|
30
|
+
} else {
|
|
31
|
+
if (n == 8 || n == 6 || n < 4) return null;
|
|
32
|
+
if (n < 6) d = "#" + d[1] + d[1] + d[2] + d[2] + d[3] + d[3] + (n > 4 ? d[4] + d[4] : "");
|
|
33
|
+
d = i(d.slice(1), 16);
|
|
34
|
+
if (n == 9 || n == 5) (x.r = (d >> 24) & 255), (x.g = (d >> 16) & 255), (x.b = (d >> 8) & 255), (x.a = m((d & 255) / 0.255) / 1000);
|
|
35
|
+
else (x.r = d >> 16), (x.g = (d >> 8) & 255), (x.b = d & 255), (x.a = -1);
|
|
36
|
+
}
|
|
37
|
+
return x;
|
|
38
|
+
};
|
|
39
|
+
(h = c0.length > 9),
|
|
40
|
+
(h = a ? (c1.length > 9 ? true : c1 == "c" ? !h : false) : h),
|
|
41
|
+
(f = pSBCr(c0)),
|
|
42
|
+
(P = p < 0),
|
|
43
|
+
(t = c1 && c1 != "c" ? pSBCr(c1) : P ? { r: 0, g: 0, b: 0, a: -1 } : { r: 255, g: 255, b: 255, a: -1 }),
|
|
44
|
+
(p = P ? p * -1 : p),
|
|
45
|
+
(P = 1 - p);
|
|
46
|
+
if (!f || !t || typeof f == "undefined") return null;
|
|
47
|
+
else if (l) (r = m(P * f.r + p * t.r)), (g = m(P * f.g + p * t.g)), (b = m(P * f.b + p * t.b));
|
|
48
|
+
else (r = m((P * f.r ** 2 + p * t.r ** 2) ** 0.5)), (g = m((P * f.g ** 2 + p * t.g ** 2) ** 0.5)), (b = m((P * f.b ** 2 + p * t.b ** 2) ** 0.5));
|
|
49
|
+
|
|
50
|
+
(a = f.a), (t = t.a), (f = a >= 0 || t >= 0), (a = f ? (a < 0 ? t : t < 0 ? a : a * P + t * p) : 0);
|
|
51
|
+
|
|
52
|
+
if (h) return "rgb" + (f ? "a(" : "(") + r + "," + g + "," + b + (f ? "," + m(a * 1000) / 1000 : "") + ")";
|
|
53
|
+
else return "#" + (4294967296 + r * 16777216 + g * 65536 + b * 256 + (f ? m(a * 255) : 0)).toString(16).slice(1, f ? undefined : -2);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const hexToRgb = (hex: string) => {
|
|
57
|
+
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
58
|
+
return result
|
|
59
|
+
? {
|
|
60
|
+
r: parseInt(result[1], 16),
|
|
61
|
+
g: parseInt(result[2], 16),
|
|
62
|
+
b: parseInt(result[3], 16),
|
|
63
|
+
}
|
|
64
|
+
: null;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const hexDarken = (hex: string, amount: number) => {
|
|
68
|
+
return pSBC(-amount, hex);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const hexLighten = (hex: string, amount: number) => {
|
|
72
|
+
return pSBC(amount, hex);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const RGBToHex = (rgb: string | any) => {
|
|
76
|
+
return pSBC(0, rgb, "c", true);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const color = {
|
|
80
|
+
random,
|
|
81
|
+
pSBC,
|
|
82
|
+
hexToRgb,
|
|
83
|
+
hexDarken,
|
|
84
|
+
hexLighten,
|
|
85
|
+
RGBToHex,
|
|
86
|
+
};
|
|
87
|
+
export default color;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import cloneDeep from "lodash/cloneDeep";
|
|
2
|
-
const _console = cloneDeep(console);
|
|
3
|
-
|
|
4
|
-
export function enableConsole() {
|
|
5
|
-
return _console;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default enableConsole;
|
|
1
|
+
import cloneDeep from "lodash/cloneDeep";
|
|
2
|
+
const _console = cloneDeep(console);
|
|
3
|
+
|
|
4
|
+
export function enableConsole() {
|
|
5
|
+
return _console;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default enableConsole;
|
package/src/console/index.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export const disableConsole = () => {
|
|
2
|
-
for (var key in console) {
|
|
3
|
-
(console as any)[key] = function () {};
|
|
4
|
-
}
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const removeConsole = disableConsole;
|
|
8
|
-
|
|
9
|
-
export const showCredit = () => {
|
|
10
|
-
console.log("Developed by Digitop | https://www.wearetopgroup.com/?utm_src=console");
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
import { enableConsole } from "./enableConsole";
|
|
14
|
-
|
|
15
|
-
const xconsole = { enableConsole, disableConsole, removeConsole, showCredit };
|
|
16
|
-
|
|
17
|
-
export default xconsole;
|
|
1
|
+
export const disableConsole = () => {
|
|
2
|
+
for (var key in console) {
|
|
3
|
+
(console as any)[key] = function () {};
|
|
4
|
+
}
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const removeConsole = disableConsole;
|
|
8
|
+
|
|
9
|
+
export const showCredit = () => {
|
|
10
|
+
console.log("Developed by Digitop | https://www.wearetopgroup.com/?utm_src=console");
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
import { enableConsole } from "./enableConsole";
|
|
14
|
+
|
|
15
|
+
const xconsole = { enableConsole, disableConsole, removeConsole, showCredit };
|
|
16
|
+
|
|
17
|
+
export default xconsole;
|
package/src/console/log.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import dayjs from "dayjs";
|
|
3
|
-
|
|
4
|
-
export const log = (...msg: any) => {
|
|
5
|
-
console.log(chalk.bgBlue.white(`[LOGGING ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), ...msg);
|
|
6
|
-
return msg;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const logFull = (data = {}) => {
|
|
10
|
-
console.dir(data, { depth: null, colors: true, maxArrayLength: null });
|
|
11
|
-
return data;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const logRes = (res: any, ...msg: any[]) => {
|
|
15
|
-
/**
|
|
16
|
-
* res.locals.req = Express Request
|
|
17
|
-
*/
|
|
18
|
-
console.warn(chalk.blue(`[${res.statusCode}] ${res.locals.req?.originalUrl || "UNKNOWN_PATH"} >> ${res.locals.req?.method} >>`), ...msg);
|
|
19
|
-
return msg;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const logError = (...msg: any[]) => {
|
|
23
|
-
console.error(chalk.bgRed.white(`[ERROR ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), chalk.red(...msg));
|
|
24
|
-
return msg;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const logWarn = (...msg: any[]) => {
|
|
28
|
-
console.warn(chalk.bgYellow.black(`[WARNING ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), ...msg);
|
|
29
|
-
return msg;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const logSuccess = (...msg: any[]) => {
|
|
33
|
-
console.info(chalk.bgGreen.black(`[SUCCESS ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), ...msg);
|
|
34
|
-
return msg;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const xlog = { log, logFull, logRes, logError, logWarn, logSuccess };
|
|
38
|
-
|
|
39
|
-
export default xlog;
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import dayjs from "dayjs";
|
|
3
|
+
|
|
4
|
+
export const log = (...msg: any) => {
|
|
5
|
+
console.log(chalk.bgBlue.white(`[LOGGING ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), ...msg);
|
|
6
|
+
return msg;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const logFull = (data = {}) => {
|
|
10
|
+
console.dir(data, { depth: null, colors: true, maxArrayLength: null });
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const logRes = (res: any, ...msg: any[]) => {
|
|
15
|
+
/**
|
|
16
|
+
* res.locals.req = Express Request
|
|
17
|
+
*/
|
|
18
|
+
console.warn(chalk.blue(`[${res.statusCode}] ${res.locals.req?.originalUrl || "UNKNOWN_PATH"} >> ${res.locals.req?.method} >>`), ...msg);
|
|
19
|
+
return msg;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const logError = (...msg: any[]) => {
|
|
23
|
+
console.error(chalk.bgRed.white(`[ERROR ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), chalk.red(...msg));
|
|
24
|
+
return msg;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const logWarn = (...msg: any[]) => {
|
|
28
|
+
console.warn(chalk.bgYellow.black(`[WARNING ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), ...msg);
|
|
29
|
+
return msg;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const logSuccess = (...msg: any[]) => {
|
|
33
|
+
console.info(chalk.bgGreen.black(`[SUCCESS ${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`), ...msg);
|
|
34
|
+
return msg;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const xlog = { log, logFull, logRes, logError, logWarn, logSuccess };
|
|
38
|
+
|
|
39
|
+
export default xlog;
|
package/src/device/browser.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
export const isPotrait = () => {
|
|
2
|
-
if (typeof window == "undefined") return false;
|
|
3
|
-
|
|
4
|
-
if (!window.orientation) return window.matchMedia("(orientation: portrait)").matches;
|
|
5
|
-
return !(window.orientation === 90 || window.orientation === -90);
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const isLandscape = () => {
|
|
9
|
-
return !isPotrait();
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const ua = () => {
|
|
13
|
-
if (typeof navigator == "undefined") return null;
|
|
14
|
-
if (typeof window == "undefined") return null;
|
|
15
|
-
|
|
16
|
-
return navigator.userAgent || navigator.vendor || (window as any).opera;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const isFacebookWebview = () => {
|
|
20
|
-
var ua: any = ua();
|
|
21
|
-
if (typeof ua != "undefined") return ua.indexOf("FBAN") > -1 || ua.indexOf("FBAV") > -1;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const isInAppWebview = () => {
|
|
25
|
-
const rules = ["WebView", "(iPhone|iPod|iPad)(?!.*Safari/)", "Android.*(wv|.0.0.0)"];
|
|
26
|
-
const regex = new RegExp(`(${rules.join("|")})`, "ig");
|
|
27
|
-
if (ua()) return Boolean(ua().match(regex));
|
|
28
|
-
return false;
|
|
29
|
-
};
|
|
1
|
+
export const isPotrait = () => {
|
|
2
|
+
if (typeof window == "undefined") return false;
|
|
3
|
+
|
|
4
|
+
if (!window.orientation) return window.matchMedia("(orientation: portrait)").matches;
|
|
5
|
+
return !(window.orientation === 90 || window.orientation === -90);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const isLandscape = () => {
|
|
9
|
+
return !isPotrait();
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const ua = () => {
|
|
13
|
+
if (typeof navigator == "undefined") return null;
|
|
14
|
+
if (typeof window == "undefined") return null;
|
|
15
|
+
|
|
16
|
+
return navigator.userAgent || navigator.vendor || (window as any).opera;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const isFacebookWebview = () => {
|
|
20
|
+
var ua: any = ua();
|
|
21
|
+
if (typeof ua != "undefined") return ua.indexOf("FBAN") > -1 || ua.indexOf("FBAV") > -1;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const isInAppWebview = () => {
|
|
25
|
+
const rules = ["WebView", "(iPhone|iPod|iPad)(?!.*Safari/)", "Android.*(wv|.0.0.0)"];
|
|
26
|
+
const regex = new RegExp(`(${rules.join("|")})`, "ig");
|
|
27
|
+
if (ua()) return Boolean(ua().match(regex));
|
|
28
|
+
return false;
|
|
29
|
+
};
|