diginext-utils 2.0.4 → 2.0.6
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/console/enableConsole.js +12 -34
- package/dist/console/index.js +7 -30
- package/dist/device/browser.js +9 -34
- package/dist/device/camera.js +4 -33
- package/dist/{chunk-QXFH3X2K.mjs → esm/chunk-5HIQS7HE.js} +1 -10
- package/dist/{chunk-AKU6F3WT.mjs → esm/chunk-EZUCZHGV.js} +1 -3
- package/dist/{chunk-A4YWYLCH.mjs → esm/chunk-HDM7KM5F.js} +1 -4
- package/dist/{chunk-FTE6FZSH.mjs → esm/chunk-LNLCKCWC.js} +1 -8
- package/dist/{chunk-2R5DRG2S.mjs → esm/chunk-X3K4KC75.js} +1 -3
- package/dist/esm/console/enableConsole.js +9 -0
- package/dist/{chunk-LXQIKFED.mjs → esm/console/index.js} +3 -5
- package/dist/{chunk-FOWYH6LL.mjs → esm/device/browser.js} +3 -7
- package/dist/{chunk-3NMJTC44.mjs → esm/device/camera.js} +3 -12
- package/dist/{file/createDir.mjs → esm/file/createDir.js} +3 -6
- package/dist/{file/fileMove.mjs → esm/file/fileMove.js} +3 -6
- package/dist/{file/findFilesByExt.mjs → esm/file/findFilesByExt.js} +3 -6
- package/dist/{math/diffDate.mjs → esm/math/diffDate.js} +3 -4
- package/dist/esm/math/index.js +2 -0
- package/dist/{math/positiveNumber.mjs → esm/math/positiveNumber.js} +4 -7
- package/dist/{name/en.mjs → esm/name/en.js} +3 -4
- package/dist/{name/vi.mjs → esm/name/vi.js} +4 -7
- package/dist/esm/permission/requestCamera.js +2 -0
- package/dist/{permission/requestDeviceOrientationControl.mjs → esm/permission/requestDeviceOrientationControl.js} +3 -4
- package/dist/{string/formatNumber.mjs → esm/string/formatNumber.js} +4 -7
- package/dist/{string/generatePassword.mjs → esm/string/generatePassword.js} +4 -10
- package/dist/{string/generateUUID.mjs → esm/string/generateUUID.js} +3 -4
- package/dist/{chunk-7UXN7I4K.mjs → esm/string/index.js} +3 -13
- package/dist/esm/string/random.js +2 -0
- package/dist/{string/trimNull.mjs → esm/string/trimNull.js} +4 -6
- package/dist/{string/url.mjs → esm/string/url.js} +4 -14
- package/dist/file/createDir.js +14 -27
- package/dist/file/fileMove.js +14 -27
- package/dist/file/findFilesByExt.js +15 -28
- package/dist/math/diffDate.js +5 -26
- package/dist/math/index.js +12 -40
- package/dist/math/positiveNumber.js +4 -27
- package/dist/name/en.js +5 -26
- package/dist/name/vi.js +4 -29
- package/dist/permission/requestCamera.js +5 -26
- package/dist/permission/requestDeviceOrientationControl.js +4 -27
- package/dist/string/formatNumber.js +4 -27
- package/dist/string/generatePassword.js +4 -27
- package/dist/string/generateUUID.js +5 -26
- package/dist/string/index.js +11 -41
- package/dist/string/random.js +10 -36
- package/dist/string/trimNull.js +12 -34
- package/dist/string/url.js +10 -40
- package/package.json +2 -2
- package/dist/.DS_Store +0 -0
- package/dist/Checker.d.ts +0 -6
- package/dist/Checker.js +0 -48
- package/dist/Checker.mjs +0 -26
- package/dist/EventDispatcher.d.ts +0 -13
- package/dist/EventDispatcher.js +0 -74
- package/dist/EventDispatcher.mjs +0 -52
- package/dist/FileUpload.d.ts +0 -12
- package/dist/FileUpload.js +0 -82
- package/dist/FileUpload.mjs +0 -60
- package/dist/Slug.d.ts +0 -5
- package/dist/Slug.js +0 -350
- package/dist/Slug.mjs +0 -328
- package/dist/Timer.d.ts +0 -5
- package/dist/Timer.js +0 -33
- package/dist/Timer.mjs +0 -7
- package/dist/Validation.d.ts +0 -6
- package/dist/Validation.js +0 -56
- package/dist/Validation.mjs +0 -34
- package/dist/array.d.ts +0 -93
- package/dist/array.js +0 -253
- package/dist/array.mjs +0 -44
- package/dist/chunk-5AL36RZR.mjs +0 -54
- package/dist/chunk-AHFJBIQJ.mjs +0 -10
- package/dist/chunk-ALNAD4H7.mjs +0 -10
- package/dist/chunk-NLQXFCPR.mjs +0 -30
- package/dist/chunk-R2BH5I6O.mjs +0 -9
- package/dist/chunk-S2U7F2JJ.mjs +0 -207
- package/dist/chunk-UKRVCU5M.mjs +0 -171
- package/dist/color.d.ts +0 -12
- package/dist/color.js +0 -95
- package/dist/color.mjs +0 -68
- package/dist/console/enableConsole.mjs +0 -11
- package/dist/console/index.mjs +0 -18
- package/dist/device/browser.mjs +0 -39
- package/dist/device/camera.mjs +0 -146
- package/dist/device.d.ts +0 -6
- package/dist/device.js +0 -197
- package/dist/device.mjs +0 -13
- package/dist/index.d.ts +0 -12
- package/dist/index.js +0 -906
- package/dist/index.mjs +0 -143
- package/dist/math/index.mjs +0 -21
- package/dist/object.d.ts +0 -25
- package/dist/object.js +0 -82
- package/dist/object.mjs +0 -17
- package/dist/permission/requestCamera.mjs +0 -7
- package/dist/string/index.mjs +0 -96
- package/dist/string/random.mjs +0 -17
package/dist/Timer.mjs
DELETED
package/dist/Validation.d.ts
DELETED
package/dist/Validation.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/Validation.ts
|
|
20
|
-
var Validation_exports = {};
|
|
21
|
-
__export(Validation_exports, {
|
|
22
|
-
Validation: () => Validation
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(Validation_exports);
|
|
25
|
-
var Validation = {
|
|
26
|
-
imageValidate(file) {
|
|
27
|
-
var maxSize = 10;
|
|
28
|
-
var fileSize = 1024 * 1024 * maxSize;
|
|
29
|
-
var fileTypes = ["image/png", "image/jpeg"];
|
|
30
|
-
if (!file || fileTypes.indexOf(file.type) < 0) {
|
|
31
|
-
alert("Vui l\xF2ng upload \u1EA3nh \u0111\xFAng \u0111\u1ECBnh d\u1EA1ng jpg hay png");
|
|
32
|
-
return false;
|
|
33
|
-
} else if (file.size > fileSize) {
|
|
34
|
-
alert("Vui l\xF2ng upload \u1EA3nh c\xF3 dung l\u01B0\u1EE3ng th\u1EA5p h\u01A1n " + maxSize + "mb");
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
return true;
|
|
38
|
-
},
|
|
39
|
-
videoValidate(file) {
|
|
40
|
-
var maxSize = 15;
|
|
41
|
-
var fileSize = 1024 * 1024 * maxSize;
|
|
42
|
-
var fileTypes = "video";
|
|
43
|
-
if (!file || file.type.indexOf(fileTypes) < 0) {
|
|
44
|
-
alert("Vui l\xF2ng upload video");
|
|
45
|
-
return false;
|
|
46
|
-
} else if (file.size > fileSize) {
|
|
47
|
-
alert("Vui l\xF2ng upload video c\xF3 dung l\u01B0\u1EE3ng th\u1EA5p h\u01A1n " + maxSize + "mb");
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
-
0 && (module.exports = {
|
|
55
|
-
Validation
|
|
56
|
-
});
|
package/dist/Validation.mjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import "./chunk-AKU6F3WT.mjs";
|
|
2
|
-
|
|
3
|
-
// src/Validation.ts
|
|
4
|
-
var Validation = {
|
|
5
|
-
imageValidate(file) {
|
|
6
|
-
var maxSize = 10;
|
|
7
|
-
var fileSize = 1024 * 1024 * maxSize;
|
|
8
|
-
var fileTypes = ["image/png", "image/jpeg"];
|
|
9
|
-
if (!file || fileTypes.indexOf(file.type) < 0) {
|
|
10
|
-
alert("Vui l\xF2ng upload \u1EA3nh \u0111\xFAng \u0111\u1ECBnh d\u1EA1ng jpg hay png");
|
|
11
|
-
return false;
|
|
12
|
-
} else if (file.size > fileSize) {
|
|
13
|
-
alert("Vui l\xF2ng upload \u1EA3nh c\xF3 dung l\u01B0\u1EE3ng th\u1EA5p h\u01A1n " + maxSize + "mb");
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
return true;
|
|
17
|
-
},
|
|
18
|
-
videoValidate(file) {
|
|
19
|
-
var maxSize = 15;
|
|
20
|
-
var fileSize = 1024 * 1024 * maxSize;
|
|
21
|
-
var fileTypes = "video";
|
|
22
|
-
if (!file || file.type.indexOf(fileTypes) < 0) {
|
|
23
|
-
alert("Vui l\xF2ng upload video");
|
|
24
|
-
return false;
|
|
25
|
-
} else if (file.size > fileSize) {
|
|
26
|
-
alert("Vui l\xF2ng upload video c\xF3 dung l\u01B0\u1EE3ng th\u1EA5p h\u01A1n " + maxSize + "mb");
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
export {
|
|
33
|
-
Validation
|
|
34
|
-
};
|
package/dist/array.d.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
declare const sumArray: (array: [], key: string) => number;
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @param {Array} array
|
|
5
|
-
* @param {string} key
|
|
6
|
-
* @returns {Number}
|
|
7
|
-
*/
|
|
8
|
-
declare const averageArray: (array: [], key: string) => number;
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {Array} array
|
|
12
|
-
* @param {string} key
|
|
13
|
-
* @returns {Number}
|
|
14
|
-
*/
|
|
15
|
-
declare const minArray: (array: [], key: string) => number;
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @param {Array} array
|
|
19
|
-
* @param {string} key
|
|
20
|
-
* @returns {Number}
|
|
21
|
-
*/
|
|
22
|
-
declare const maxArray: (array: [], key: string) => number;
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* @param {Array} array
|
|
26
|
-
* @param {string} key
|
|
27
|
-
* @returns {Array}
|
|
28
|
-
*/
|
|
29
|
-
declare const sortElementByString: (array: any, key: string) => any[];
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* @param {Array} array
|
|
33
|
-
* @param {string} key
|
|
34
|
-
* @returns {Array}
|
|
35
|
-
*/
|
|
36
|
-
declare const sortElementByNumber: (array: any, key: string) => any[];
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
* @param {Array} array
|
|
40
|
-
* @returns {any}
|
|
41
|
-
*/
|
|
42
|
-
declare const firstElement: (array: any[]) => any;
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @param {Array} array
|
|
46
|
-
* @returns {any}
|
|
47
|
-
*/
|
|
48
|
-
declare const lastElement: (array: any[]) => any;
|
|
49
|
-
/**
|
|
50
|
-
*
|
|
51
|
-
* @param {Array} array
|
|
52
|
-
* @returns {any}
|
|
53
|
-
*/
|
|
54
|
-
declare const randomIndex: (array: any[]) => number;
|
|
55
|
-
/**
|
|
56
|
-
*
|
|
57
|
-
* @param {Array} array
|
|
58
|
-
* @returns {any}
|
|
59
|
-
*/
|
|
60
|
-
declare const randomElement: (array: any[]) => any;
|
|
61
|
-
/**
|
|
62
|
-
* Remove same elements from 2 arrays
|
|
63
|
-
*/
|
|
64
|
-
declare const mergeAndMakeUniqueElement: (list1: any[], list2: any[], key: string) => any[];
|
|
65
|
-
/**
|
|
66
|
-
* check target == toMatch
|
|
67
|
-
* @param {Array} target
|
|
68
|
-
* @param {Array} toMatch
|
|
69
|
-
* @returns {Boolean}
|
|
70
|
-
*/
|
|
71
|
-
declare const allMatchInArray: (target: any[], toMatch: any[]) => boolean;
|
|
72
|
-
declare const removeItem: (item: any, array: any[]) => any[];
|
|
73
|
-
declare const removeItemByKey: (key: string, value: any, array: any[]) => any[];
|
|
74
|
-
declare const getRandom: (array: any[], n: number) => any[];
|
|
75
|
-
/**
|
|
76
|
-
* Get an array with shuffle element
|
|
77
|
-
*/
|
|
78
|
-
declare const getHalfRandom: (array: any[], n: number) => any[];
|
|
79
|
-
/**
|
|
80
|
-
* Make array shuffle itself
|
|
81
|
-
*/
|
|
82
|
-
declare const shuffle: (array: any[]) => any[];
|
|
83
|
-
/**
|
|
84
|
-
*
|
|
85
|
-
* @param {Array} array
|
|
86
|
-
* @param {Number} oldIndex
|
|
87
|
-
* @param {Number} newIndex
|
|
88
|
-
* @returns {Array}
|
|
89
|
-
*/
|
|
90
|
-
declare const moveIndex: (array: any[], oldIndex: number, newIndex: number) => any[];
|
|
91
|
-
declare const moveArray: (array: any[], oldIndex: number, newIndex: number) => any[];
|
|
92
|
-
|
|
93
|
-
export { allMatchInArray, averageArray, firstElement, getHalfRandom, getRandom, lastElement, maxArray, mergeAndMakeUniqueElement, minArray, moveArray, moveIndex, randomElement, randomIndex, removeItem, removeItemByKey, shuffle, sortElementByNumber, sortElementByString, sumArray };
|
package/dist/array.js
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/array.ts
|
|
20
|
-
var array_exports = {};
|
|
21
|
-
__export(array_exports, {
|
|
22
|
-
allMatchInArray: () => allMatchInArray,
|
|
23
|
-
averageArray: () => averageArray,
|
|
24
|
-
firstElement: () => firstElement,
|
|
25
|
-
getHalfRandom: () => getHalfRandom,
|
|
26
|
-
getRandom: () => getRandom,
|
|
27
|
-
lastElement: () => lastElement,
|
|
28
|
-
maxArray: () => maxArray,
|
|
29
|
-
mergeAndMakeUniqueElement: () => mergeAndMakeUniqueElement,
|
|
30
|
-
minArray: () => minArray,
|
|
31
|
-
moveArray: () => moveArray,
|
|
32
|
-
moveIndex: () => moveIndex,
|
|
33
|
-
randomElement: () => randomElement,
|
|
34
|
-
randomIndex: () => randomIndex,
|
|
35
|
-
removeItem: () => removeItem,
|
|
36
|
-
removeItemByKey: () => removeItemByKey,
|
|
37
|
-
shuffle: () => shuffle,
|
|
38
|
-
sortElementByNumber: () => sortElementByNumber,
|
|
39
|
-
sortElementByString: () => sortElementByString,
|
|
40
|
-
sumArray: () => sumArray
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(array_exports);
|
|
43
|
-
|
|
44
|
-
// src/math/index.ts
|
|
45
|
-
var DEG2RAD = Math.PI / 180;
|
|
46
|
-
var RAD2DEG = 180 / Math.PI;
|
|
47
|
-
var randInt = (low, high) => {
|
|
48
|
-
return low + Math.floor(Math.random() * (high - low + 1));
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// src/array.ts
|
|
52
|
-
var sumArray = (array, key) => {
|
|
53
|
-
if (!array) {
|
|
54
|
-
console.warn("ARRAY NOT EXITED !");
|
|
55
|
-
return 0;
|
|
56
|
-
}
|
|
57
|
-
if (key)
|
|
58
|
-
return array.reduce((c, v) => c + v[key], 0);
|
|
59
|
-
else
|
|
60
|
-
return array.reduce((c, v) => c + v, 0);
|
|
61
|
-
};
|
|
62
|
-
var averageArray = (array, key) => {
|
|
63
|
-
if (!array) {
|
|
64
|
-
console.warn("ARRAY NOT EXITED !");
|
|
65
|
-
return 0;
|
|
66
|
-
}
|
|
67
|
-
return sumArray(array, key) / array.length || 0;
|
|
68
|
-
};
|
|
69
|
-
var minArray = (array, key) => {
|
|
70
|
-
if (!array) {
|
|
71
|
-
console.warn("ARRAY NOT EXITED !");
|
|
72
|
-
return 0;
|
|
73
|
-
}
|
|
74
|
-
if (array.length > 0) {
|
|
75
|
-
if (key)
|
|
76
|
-
return array.reduce((c, v) => c < v[key] ? c : v[key]);
|
|
77
|
-
else
|
|
78
|
-
return array.reduce((c, v) => c < v ? c : v);
|
|
79
|
-
}
|
|
80
|
-
return 0;
|
|
81
|
-
};
|
|
82
|
-
var maxArray = (array, key) => {
|
|
83
|
-
if (!array) {
|
|
84
|
-
console.warn("ARRAY NOT EXITED !");
|
|
85
|
-
return 0;
|
|
86
|
-
}
|
|
87
|
-
if (array.length > 0) {
|
|
88
|
-
if (key)
|
|
89
|
-
return array.reduce((c, v) => c > v[key] ? c : v[key]);
|
|
90
|
-
else
|
|
91
|
-
return array.reduce((c, v) => c > v ? c : v);
|
|
92
|
-
}
|
|
93
|
-
return 0;
|
|
94
|
-
};
|
|
95
|
-
var sortElementByString = (array, key) => {
|
|
96
|
-
if (!Array.isArray(array))
|
|
97
|
-
return [];
|
|
98
|
-
if (key)
|
|
99
|
-
return array.sort((x, y) => {
|
|
100
|
-
var a = x[key].toUpperCase(), b = y[key].toUpperCase();
|
|
101
|
-
return a == b ? 0 : a > b ? 1 : -1;
|
|
102
|
-
});
|
|
103
|
-
console.log("NO KEY");
|
|
104
|
-
};
|
|
105
|
-
var sortElementByNumber = (array, key) => {
|
|
106
|
-
if (!Array.isArray(array))
|
|
107
|
-
return [];
|
|
108
|
-
if (key)
|
|
109
|
-
return array.sort((a, b) => {
|
|
110
|
-
return a[key] - b[key];
|
|
111
|
-
});
|
|
112
|
-
console.log("NO KEY");
|
|
113
|
-
};
|
|
114
|
-
var firstElement = (array) => {
|
|
115
|
-
if (array) {
|
|
116
|
-
if (array.length || array.length > 0)
|
|
117
|
-
return array[0];
|
|
118
|
-
}
|
|
119
|
-
return null;
|
|
120
|
-
};
|
|
121
|
-
var lastElement = (array) => {
|
|
122
|
-
if (array) {
|
|
123
|
-
if (array.length || array.length > 0)
|
|
124
|
-
return array[array.length - 1];
|
|
125
|
-
}
|
|
126
|
-
return null;
|
|
127
|
-
};
|
|
128
|
-
var randomIndex = (array) => {
|
|
129
|
-
if (array)
|
|
130
|
-
return randInt(0, array.length - 1);
|
|
131
|
-
return -1;
|
|
132
|
-
};
|
|
133
|
-
var randomElement = (array) => {
|
|
134
|
-
if (array)
|
|
135
|
-
return array[randomIndex(array)];
|
|
136
|
-
return null;
|
|
137
|
-
};
|
|
138
|
-
var mergeAndMakeUniqueElement = (list1, list2, key) => {
|
|
139
|
-
if (!list1 || !list2)
|
|
140
|
-
return;
|
|
141
|
-
if (key) {
|
|
142
|
-
return list1.concat(list2).filter((item, index, self) => {
|
|
143
|
-
return self.findIndex((x) => x[key] == item[key]) === index;
|
|
144
|
-
});
|
|
145
|
-
} else {
|
|
146
|
-
return list1.concat(list2).filter((x, index, self) => {
|
|
147
|
-
return self.indexOf(x) === index;
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
var allMatchInArray = (target, toMatch) => {
|
|
152
|
-
if (!target || !toMatch)
|
|
153
|
-
return false;
|
|
154
|
-
const found = toMatch.every((item) => {
|
|
155
|
-
return target.includes(item);
|
|
156
|
-
});
|
|
157
|
-
return found;
|
|
158
|
-
};
|
|
159
|
-
var removeItem = (item, array) => {
|
|
160
|
-
const index = array.indexOf(item);
|
|
161
|
-
if (index == -1) {
|
|
162
|
-
console.warn("[ArrayExtra.removeItem] Item not found.");
|
|
163
|
-
return array;
|
|
164
|
-
}
|
|
165
|
-
array.splice(index, 1);
|
|
166
|
-
return array;
|
|
167
|
-
};
|
|
168
|
-
var removeItemByKey = (key, value, array) => {
|
|
169
|
-
const foundIndex = array.findIndex((item) => {
|
|
170
|
-
return item[key] == value;
|
|
171
|
-
});
|
|
172
|
-
if (foundIndex < 0) {
|
|
173
|
-
console.warn("[ArrayExtra.removeItemByKey] Item not found.", key, value);
|
|
174
|
-
return array;
|
|
175
|
-
}
|
|
176
|
-
array.splice(foundIndex, 1);
|
|
177
|
-
return array;
|
|
178
|
-
};
|
|
179
|
-
var getRandom = (array, n) => {
|
|
180
|
-
var result = new Array(n), len = array.length, taken = new Array(len);
|
|
181
|
-
if (n > len)
|
|
182
|
-
throw new RangeError("getRandom: more elements taken than available");
|
|
183
|
-
while (n--) {
|
|
184
|
-
var x = Math.floor(Math.random() * len);
|
|
185
|
-
result[n] = array[x in taken ? taken[x] : x];
|
|
186
|
-
taken[x] = --len in taken ? taken[len] : len;
|
|
187
|
-
}
|
|
188
|
-
return result;
|
|
189
|
-
};
|
|
190
|
-
var getHalfRandom = (array, n) => {
|
|
191
|
-
var n = Math.ceil(array.length / 2);
|
|
192
|
-
return getRandom(array, n);
|
|
193
|
-
};
|
|
194
|
-
var shuffle = (array) => {
|
|
195
|
-
var i = array.length, j, temp;
|
|
196
|
-
if (array.length < 1)
|
|
197
|
-
return array;
|
|
198
|
-
while (--i) {
|
|
199
|
-
j = Math.floor(Math.random() * (i + 1));
|
|
200
|
-
temp = array[i];
|
|
201
|
-
array[i] = array[j];
|
|
202
|
-
array[j] = temp;
|
|
203
|
-
}
|
|
204
|
-
return array;
|
|
205
|
-
};
|
|
206
|
-
var moveIndex = (array, oldIndex, newIndex) => {
|
|
207
|
-
if (newIndex >= array.length) {
|
|
208
|
-
var k = newIndex - array.length + 1;
|
|
209
|
-
while (k--) {
|
|
210
|
-
array.push(void 0);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
array.splice(newIndex, 0, array.splice(oldIndex, 1)[0]);
|
|
214
|
-
return array;
|
|
215
|
-
};
|
|
216
|
-
var moveArray = (array, oldIndex, newIndex) => {
|
|
217
|
-
while (oldIndex < 0) {
|
|
218
|
-
oldIndex += array.length;
|
|
219
|
-
}
|
|
220
|
-
while (newIndex < 0) {
|
|
221
|
-
newIndex += array.length;
|
|
222
|
-
}
|
|
223
|
-
if (newIndex >= array.length) {
|
|
224
|
-
var k = newIndex - array.length;
|
|
225
|
-
while (k-- + 1) {
|
|
226
|
-
array.push(999);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
array.splice(newIndex, 0, array.splice(oldIndex, 1)[0]);
|
|
230
|
-
return array;
|
|
231
|
-
};
|
|
232
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
233
|
-
0 && (module.exports = {
|
|
234
|
-
allMatchInArray,
|
|
235
|
-
averageArray,
|
|
236
|
-
firstElement,
|
|
237
|
-
getHalfRandom,
|
|
238
|
-
getRandom,
|
|
239
|
-
lastElement,
|
|
240
|
-
maxArray,
|
|
241
|
-
mergeAndMakeUniqueElement,
|
|
242
|
-
minArray,
|
|
243
|
-
moveArray,
|
|
244
|
-
moveIndex,
|
|
245
|
-
randomElement,
|
|
246
|
-
randomIndex,
|
|
247
|
-
removeItem,
|
|
248
|
-
removeItemByKey,
|
|
249
|
-
shuffle,
|
|
250
|
-
sortElementByNumber,
|
|
251
|
-
sortElementByString,
|
|
252
|
-
sumArray
|
|
253
|
-
});
|
package/dist/array.mjs
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
allMatchInArray,
|
|
3
|
-
averageArray,
|
|
4
|
-
firstElement,
|
|
5
|
-
getHalfRandom,
|
|
6
|
-
getRandom,
|
|
7
|
-
lastElement,
|
|
8
|
-
maxArray,
|
|
9
|
-
mergeAndMakeUniqueElement,
|
|
10
|
-
minArray,
|
|
11
|
-
moveArray,
|
|
12
|
-
moveIndex,
|
|
13
|
-
randomElement,
|
|
14
|
-
randomIndex,
|
|
15
|
-
removeItem,
|
|
16
|
-
removeItemByKey,
|
|
17
|
-
shuffle,
|
|
18
|
-
sortElementByNumber,
|
|
19
|
-
sortElementByString,
|
|
20
|
-
sumArray
|
|
21
|
-
} from "./chunk-S2U7F2JJ.mjs";
|
|
22
|
-
import "./chunk-QXFH3X2K.mjs";
|
|
23
|
-
import "./chunk-AKU6F3WT.mjs";
|
|
24
|
-
export {
|
|
25
|
-
allMatchInArray,
|
|
26
|
-
averageArray,
|
|
27
|
-
firstElement,
|
|
28
|
-
getHalfRandom,
|
|
29
|
-
getRandom,
|
|
30
|
-
lastElement,
|
|
31
|
-
maxArray,
|
|
32
|
-
mergeAndMakeUniqueElement,
|
|
33
|
-
minArray,
|
|
34
|
-
moveArray,
|
|
35
|
-
moveIndex,
|
|
36
|
-
randomElement,
|
|
37
|
-
randomIndex,
|
|
38
|
-
removeItem,
|
|
39
|
-
removeItemByKey,
|
|
40
|
-
shuffle,
|
|
41
|
-
sortElementByNumber,
|
|
42
|
-
sortElementByString,
|
|
43
|
-
sumArray
|
|
44
|
-
};
|
package/dist/chunk-5AL36RZR.mjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// src/object.ts
|
|
2
|
-
var isNull = (object) => {
|
|
3
|
-
if (typeof object == "undefined")
|
|
4
|
-
return true;
|
|
5
|
-
if (object == "")
|
|
6
|
-
return true;
|
|
7
|
-
if (Array.isArray(object))
|
|
8
|
-
return object.length == 0;
|
|
9
|
-
if (JSON.stringify(object) == "{}")
|
|
10
|
-
return true;
|
|
11
|
-
return object == null;
|
|
12
|
-
};
|
|
13
|
-
var toBool = (object) => {
|
|
14
|
-
if (isNull(object))
|
|
15
|
-
return false;
|
|
16
|
-
object = object.toString();
|
|
17
|
-
return object === "true" || object == "1";
|
|
18
|
-
};
|
|
19
|
-
var toInt = (object) => {
|
|
20
|
-
if (isNull(object))
|
|
21
|
-
return 0;
|
|
22
|
-
object = object.toString();
|
|
23
|
-
return parseInt(object, 10);
|
|
24
|
-
};
|
|
25
|
-
var toFloat = (object) => {
|
|
26
|
-
if (isNull(object))
|
|
27
|
-
return 0;
|
|
28
|
-
object = object.toString();
|
|
29
|
-
return parseFloat(object);
|
|
30
|
-
};
|
|
31
|
-
var toArray = (obj) => {
|
|
32
|
-
if (isNull(obj))
|
|
33
|
-
return [];
|
|
34
|
-
if (!Array.isArray(obj)) {
|
|
35
|
-
obj = [obj];
|
|
36
|
-
}
|
|
37
|
-
return obj;
|
|
38
|
-
};
|
|
39
|
-
var objectToArray = (obj) => {
|
|
40
|
-
const array = [];
|
|
41
|
-
for (const key in obj) {
|
|
42
|
-
array.push(obj[key]);
|
|
43
|
-
}
|
|
44
|
-
return array;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export {
|
|
48
|
-
isNull,
|
|
49
|
-
toBool,
|
|
50
|
-
toInt,
|
|
51
|
-
toFloat,
|
|
52
|
-
toArray,
|
|
53
|
-
objectToArray
|
|
54
|
-
};
|
package/dist/chunk-AHFJBIQJ.mjs
DELETED
package/dist/chunk-ALNAD4H7.mjs
DELETED
package/dist/chunk-NLQXFCPR.mjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isAndroid
|
|
3
|
-
} from "./chunk-UKRVCU5M.mjs";
|
|
4
|
-
|
|
5
|
-
// src/permission/requestDeviceOrientationControl.ts
|
|
6
|
-
var requestDeviceOrientationControl = () => {
|
|
7
|
-
if (typeof window == "undefined")
|
|
8
|
-
return false;
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
if (isAndroid())
|
|
11
|
-
resolve(true);
|
|
12
|
-
if (typeof DeviceMotionEvent != "undefined" && DeviceMotionEvent.requestPermission) {
|
|
13
|
-
DeviceMotionEvent.requestPermission().then((response) => {
|
|
14
|
-
if (response == "granted") {
|
|
15
|
-
resolve(true);
|
|
16
|
-
} else {
|
|
17
|
-
resolve(false);
|
|
18
|
-
}
|
|
19
|
-
}).catch((response) => {
|
|
20
|
-
resolve(false);
|
|
21
|
-
});
|
|
22
|
-
} else {
|
|
23
|
-
resolve(false);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export {
|
|
29
|
-
requestDeviceOrientationControl
|
|
30
|
-
};
|