diginext-utils 2.0.1 → 2.0.2

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.
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Check if the object or string is in JSON format
3
+ */
4
+ declare const isJSON: (content: object | string) => boolean;
5
+
6
+ export { isJSON };
@@ -0,0 +1,13 @@
1
+ declare class EventDispatcher {
2
+ constructor();
3
+ _listeners: any;
4
+ addEventListener(type: string, listener: any): void;
5
+ hasEventListener(type: string, listener: any): boolean;
6
+ removeEventListener(type: string, listener: any): void;
7
+ dispatchEvent(event: {
8
+ type: string;
9
+ target: any;
10
+ }): void;
11
+ }
12
+
13
+ export { EventDispatcher as default };
@@ -0,0 +1,12 @@
1
+ declare type UploadParams = {
2
+ blob: Blob;
3
+ url: string;
4
+ params: any;
5
+ onComplete: any;
6
+ onError: any;
7
+ };
8
+ declare const FileUpload: {
9
+ uploadBlob(props: UploadParams): void;
10
+ };
11
+
12
+ export { FileUpload as default };
package/dist/Slug.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ declare const makeSlug: (s: string, opt?: {
2
+ [key: string]: any;
3
+ }) => string;
4
+
5
+ export { makeSlug };
@@ -0,0 +1,5 @@
1
+ declare const Timer: {
2
+ wait: (ms: number) => Promise<unknown>;
3
+ };
4
+
5
+ export { Timer as default };
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ imageValidate(file: Blob): boolean;
3
+ videoValidate(file: Blob): boolean;
4
+ };
5
+
6
+ export { _default as default };
@@ -0,0 +1,93 @@
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 };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Create new directory
3
+ */
4
+ declare function createDir(path: string): boolean;
5
+
6
+ export { createDir as default };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Move file to another location.
3
+ */
4
+ declare function fileMove(oldPath: string, newPath: string, callback: any): void;
5
+
6
+ export { fileMove as default };
@@ -0,0 +1,6 @@
1
+ /**
2
+ *
3
+ */
4
+ declare const forEachFileByExt: (base: string, ext: string, cb: (path: string) => {}) => void;
5
+
6
+ export { forEachFileByExt as default };
@@ -0,0 +1,12 @@
1
+ declare const random: (hex?: boolean) => string;
2
+ declare const pSBC: (p: any, c0: any, c1?: any, l?: any) => string;
3
+ declare const hexToRgb: (hex: string) => {
4
+ r: number;
5
+ g: number;
6
+ b: number;
7
+ };
8
+ declare const hexDarken: (hex: string, amount: number) => string;
9
+ declare const hexLighten: (hex: string, amount: number) => string;
10
+ declare const RGBToHex: (rgb: string | any) => string;
11
+
12
+ export { RGBToHex, hexDarken, hexLighten, hexToRgb, pSBC, random };
@@ -0,0 +1,3 @@
1
+ declare function enableConsole(): Console;
2
+
3
+ export { enableConsole as default };
@@ -0,0 +1,5 @@
1
+ declare const disableConsole: (params: any) => void;
2
+ declare const removeConsole: (params: any) => void;
3
+ declare const showCredit: (params: any) => void;
4
+
5
+ export { disableConsole, removeConsole, showCredit };
@@ -0,0 +1,7 @@
1
+ declare const isPotrait: () => boolean;
2
+ declare const isLandscape: () => boolean;
3
+ declare const ua: () => any;
4
+ declare const isFacebookWebview: () => boolean;
5
+ declare const isInAppWebview: () => boolean;
6
+
7
+ export { isFacebookWebview, isInAppWebview, isLandscape, isPotrait, ua };
@@ -0,0 +1,16 @@
1
+ /**
2
+ *
3
+ * @param {{
4
+ * container,
5
+ * facingMode : environment | user,
6
+ * audio : boolean,
7
+ * }} param0
8
+ * @returns
9
+ */
10
+ declare function getWebcam({ container, facingMode, audio, }: {
11
+ container: any;
12
+ facingMode?: string;
13
+ audio?: boolean;
14
+ }): Promise<unknown>;
15
+
16
+ export { getWebcam };
@@ -0,0 +1,6 @@
1
+ declare const isIos: () => boolean;
2
+ declare const isAndroid: () => boolean;
3
+ declare const isMobile: () => boolean;
4
+ declare const checkOS: () => any;
5
+
6
+ export { checkOS, isAndroid, isIos, isMobile };
@@ -0,0 +1,13 @@
1
+ export { allMatchInArray, averageArray, firstElement, getHalfRandom, getRandom, lastElement, maxArray, mergeAndMakeUniqueElement, minArray, moveArray, moveIndex, randomElement, randomIndex, removeItem, removeItemByKey, shuffle, sortElementByNumber, sortElementByString, sumArray } from './array.js';
2
+ export { checkOS, isAndroid, isIos, isMobile } from './device.js';
3
+ export { disableConsole, removeConsole, showCredit } from './console/index.js';
4
+ export { isFacebookWebview, isInAppWebview, isLandscape, isPotrait, ua } from './device/browser.js';
5
+ export { getWebcam } from './device/camera.js';
6
+ export { angleBetweenPoints, degToRad, radToDeg, rand, randFloat, randHalt, randInt, randRound } from './math.js';
7
+ export { isNull, objectToArray, toArray, toBool, toFloat, toInt } from './object.js';
8
+ export { capitalize, capitalizeName, clearUnicodeCharacters, getBetween, makeString, titleize, toLowerCase, toUpperCase } from './string.js';
9
+ export { addQueryParam, getFileExtension, getFileNameWithExtension, getFileNameWithoutExtension, getUrlParams, isImage, isLink } from './string/url.js';
10
+ export { default as Timer } from './Timer.js';
11
+ export { default as requestCamera } from './permission/requestCamera.js';
12
+ export { default as requestDeviceOrientationControl } from './permission/requestDeviceOrientationControl.js';
13
+ export { default as enableConsole } from './console/enableConsole.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns amount of different days between 2 dates
3
+ */
4
+ declare function diffDate(date1: string, date2: string): number;
5
+
6
+ export { diffDate as default };
@@ -0,0 +1,3 @@
1
+ declare function positiveNumber(number: number): number;
2
+
3
+ export { positiveNumber as default };
package/dist/math.d.ts ADDED
@@ -0,0 +1,55 @@
1
+ /**
2
+ *
3
+ * @param {Number} number
4
+ * @return {Number}
5
+ */
6
+ declare const randRound: (number: number) => number;
7
+ /**
8
+ *
9
+ * @param {Number} number
10
+ * @return {Number}
11
+ */
12
+ declare const rand: (number: number) => number;
13
+ /**
14
+ *
15
+ * @param {Number} number
16
+ * @return {Number}
17
+ */
18
+ declare const randHalt: (number: number) => number;
19
+ /**
20
+ *
21
+ * @param {Number} low
22
+ * @param {Number} high
23
+ * @return {Number}
24
+ */
25
+ declare const randInt: (low: number, high: number) => number;
26
+ /**
27
+ *
28
+ * @param {Number} low
29
+ * @param {Number} high
30
+ * @return {Number}
31
+ */
32
+ declare const randFloat: (low: number, high: number) => number;
33
+ /**
34
+ *
35
+ * @param {Number} degrees
36
+ * @return {Number}
37
+ */
38
+ declare const degToRad: (degrees: number) => number;
39
+ /**
40
+ *
41
+ * @param {Number} degrees
42
+ * @return {Number}
43
+ */
44
+ declare const radToDeg: (radians: number) => number;
45
+ /**
46
+ *
47
+ * @param {Number} cx
48
+ * @param {Number} cy
49
+ * @param {Number} ex
50
+ * @param {Number} ey
51
+ * @returns {Number}
52
+ */
53
+ declare const angleBetweenPoints: (cx: number, cy: number, ex: number, ey: number) => number;
54
+
55
+ export { angleBetweenPoints, degToRad, radToDeg, rand, randFloat, randHalt, randInt, randRound };
@@ -0,0 +1,25 @@
1
+ declare const isNull: (object: string | number | {
2
+ [key: string]: any;
3
+ }) => boolean;
4
+ declare const toBool: (object: string | {
5
+ [key: string]: any;
6
+ }) => boolean;
7
+ declare const toInt: (object: string | number | {
8
+ [key: string]: any;
9
+ }) => number;
10
+ declare const toFloat: (object: string | {
11
+ [key: string]: any;
12
+ }) => number;
13
+ declare const toArray: (obj: {
14
+ [key: string]: any;
15
+ }) => {
16
+ [key: string]: any;
17
+ };
18
+ /**
19
+ * Convert value in object to array
20
+ */
21
+ declare const objectToArray: (obj: {
22
+ [key: string]: any;
23
+ }) => any[];
24
+
25
+ export { isNull, objectToArray, toArray, toBool, toFloat, toInt };
@@ -0,0 +1,6 @@
1
+ declare const requestCamera: ({ audio, video }: {
2
+ audio?: boolean;
3
+ video?: boolean;
4
+ }) => false | Promise<unknown>;
5
+
6
+ export { requestCamera as default };
@@ -0,0 +1,3 @@
1
+ declare const requestDeviceOrientationControl: () => false | Promise<unknown>;
2
+
3
+ export { requestDeviceOrientationControl as default };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Format the input number with commas
3
+ * @example 1000000 -> 1,000,000
4
+ */
5
+ declare function formatNumber(num: number, prefix?: string): string;
6
+
7
+ export { formatNumber as default };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * random password
3
+ * - if hard = true -> random punctuation inside
4
+ * @param {*} length
5
+ * @param {Boolean} hard
6
+ * @returns
7
+ */
8
+ declare function generatePassword(length?: number, hard?: boolean): string;
9
+
10
+ export { generatePassword as default };
@@ -0,0 +1,3 @@
1
+ declare function generateUUID(): string;
2
+
3
+ export { generateUUID as default };
@@ -0,0 +1,3 @@
1
+ declare function generateName(): string;
2
+
3
+ export { generateName };
@@ -0,0 +1,3 @@
1
+ declare const generateName: (useGender?: boolean, male?: boolean) => Promise<any>;
2
+
3
+ export { generateName };
@@ -0,0 +1,11 @@
1
+ declare const textLowCase = "abcdefghijklmnopqrstuvwxyz";
2
+ declare const numeric = "0123456789";
3
+ declare const punctuation = "!@#$%^&*()_+~|}{[];?><,./-=";
4
+ declare const allCharacter = "\u0111\u0110a\u00E1\u00E0\u1EA3\u00E3\u1EA1\u0103\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u00E2\u1EA5\u1EA7\u1EA9\u1EAB\u1EADe\u00E9\u00E8\u1EBB\u1EBD\u1EB9\u00EA\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7o\u00F3\u00F2\u1ECF\u00F5\u1ECD\u00F4\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u01A1\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3i\u00ED\u00EC\u1EC9\u0129\u1ECBu\u00FA\u00F9\u1EE7\u0169\u1EE5\u01B0\u1EE9\u1EEB\u1EED\u1EEF\u1EF1y\u00FD\u1EF3\u1EF7\u1EF9\u1EF5A\u00C1\u00C0\u1EA2\u00C3\u1EA0\u0102\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u00C2\u1EA4\u1EA6\u1EA8\u1EAA\u1EACE\u00C9\u00C8\u1EBA\u1EBC\u1EB8\u00CA\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6O\u00D3\u00D2\u1ECE\u00D5\u1ECC\u00D4\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u01A0\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2I\u00CD\u00CC\u1EC8\u0128\u1ECAU\u00DA\u00D9\u1EE6\u0168\u1EE4\u01AF\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0Y\u00DD\u1EF2 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}";
5
+ /**
6
+ * allCharacter = `đĐaáàảãạăắằẳẵặâấầẩẫậeéèẻẽẹêếềểễệoóòỏõọôốồổỗộơớờởỡợiíìỉĩịuúùủũụưứừửữựyýỳỷỹỵAÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬEÉÈẺẼẸÊẾỀỂỄỆOÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢIÍÌỈĨỊUÚÙỦŨỤƯỨỪỬỮỰYÝỲ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}`;
7
+ */
8
+ declare const randAllCharacterByLength: (length?: number) => string;
9
+ declare const randomStringByLength: (length: number, str?: string) => string;
10
+
11
+ export { allCharacter, numeric, punctuation, randAllCharacterByLength, randomStringByLength, textLowCase };
@@ -0,0 +1,3 @@
1
+ declare function trimNull(str: string): string;
2
+
3
+ export { trimNull as default };
@@ -0,0 +1,33 @@
1
+ declare const addQueryParam: (_url: string, key: string, value: any) => string;
2
+ declare const getUrlParams: (parameter: string, staticURL?: string, decode?: boolean) => string | false;
3
+ /**
4
+ *
5
+ * @return {boolean}
6
+ */
7
+ declare const isLink: (str: string) => boolean;
8
+ /**
9
+ *
10
+ * @param {string} url
11
+ * @return {string}
12
+ */
13
+ declare const getFileNameWithoutExtension: (url: string) => string;
14
+ /**
15
+ *
16
+ * @param {string} url
17
+ * @return {string}
18
+ */
19
+ declare const getFileNameWithExtension: (url: string) => string;
20
+ /**
21
+ *
22
+ * @param {string} url
23
+ * @return {string}
24
+ */
25
+ declare const getFileExtension: (url: string) => string;
26
+ /**
27
+ *
28
+ * @param {string} url
29
+ * @returns
30
+ */
31
+ declare const isImage: (url: string) => boolean;
32
+
33
+ export { addQueryParam, getFileExtension, getFileNameWithExtension, getFileNameWithoutExtension, getUrlParams, isImage, isLink };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Get string between str1 and str2 from text
3
+ */
4
+ declare const getBetween: (text: string, str1: string, str2?: string) => string;
5
+ /**
6
+ * Convert object to string
7
+ */
8
+ declare const makeString: (object?: any) => string;
9
+ /**
10
+ * toUpperCase
11
+ */
12
+ declare const toUpperCase: (str?: string) => string;
13
+ /**
14
+ * toLowerCase
15
+ */
16
+ declare const toLowerCase: (str?: string) => string;
17
+ /**
18
+ * toLowerCase
19
+ * @param {*} str
20
+ * @return {string}
21
+ */
22
+ declare const titleize: (str?: string) => string;
23
+ /**
24
+ * Convert only first charater to UpperCase
25
+ */
26
+ declare const capitalize: (str: string | any, lowercaseRest?: number) => any;
27
+ /**
28
+ * Convert first character from every single words to UpperCase
29
+ */
30
+ declare const capitalizeName: (str: string) => string;
31
+ declare const clearUnicodeCharacters: (s: string, opt?: {
32
+ [key: string]: any;
33
+ }) => string;
34
+
35
+ export { capitalize, capitalizeName, clearUnicodeCharacters, getBetween, makeString, titleize, toLowerCase, toUpperCase };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginext-utils",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "sideEffects": false,
5
5
  "author": {
6
6
  "name": "TOP GROUP (a.k.a Digitop)",
@@ -11,9 +11,6 @@
11
11
  "files": [
12
12
  "dist/**"
13
13
  ],
14
- "exports": {
15
- ".": "./dist"
16
- },
17
14
  "scripts": {
18
15
  "build": "tsup src/**/*.ts --treeshake --format esm,cjs --dts",
19
16
  "dev": "concurrently \"tsup src/index.ts --treeshake --format esm,cjs --dts --watch",