@lowentry/utils 1.22.1 → 1.22.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowentry/utils",
3
- "version": "1.22.1",
3
+ "version": "1.22.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "scripts": {
21
21
  "build": "npm exec -- rollup -c",
22
- "prepublishOnly": "rm -r src && mv dist/* ./ && rm -r dist",
22
+ "prepublishOnly": "rm -r build && rm -r tests && rm -r src && mv dist/* ./ && rm -r dist",
23
23
  "test": "npx tsc && vitest run"
24
24
  },
25
25
  "dependencies": {
@@ -1,15 +0,0 @@
1
- export function ISSET(value: any): boolean;
2
- export function IS_ARRAY(value: any): boolean;
3
- export function ARRAY(value: any): any[];
4
- export function IS_OBJECT(value: any): boolean;
5
- export function OBJECT(value: any): any;
6
- export function STRING(value: any): string;
7
- export function STRING_ANY(...values: any): string;
8
- export function INT(value: any): number;
9
- export function INT_ANY(...values: any): number;
10
- export function FLOAT(value: any): number;
11
- export function FLOAT_ANY(...values: any): number;
12
- export function INT_LAX(value: any): number;
13
- export function INT_LAX_ANY(...values: any): number;
14
- export function FLOAT_LAX(value: any): number;
15
- export function FLOAT_LAX_ANY(...values: any): number;
@@ -1,203 +0,0 @@
1
- export namespace LeUtils {
2
- function equals(value: any, other: any): boolean;
3
- function equalsMapLike(elementsA: any, elementsB: any, ignoreKeys?: any[]): boolean;
4
- function clone(value: any): any;
5
- function onDomReady(callback: Function): {
6
- remove: Function;
7
- };
8
- function parseVersionString(versionString: string | any): {
9
- major: (number);
10
- minor: (number);
11
- patch: (number);
12
- toString: (() => string);
13
- equals: ((arg0: string | any) => boolean);
14
- smallerThan: ((arg0: string | any) => boolean);
15
- smallerThanOrEquals: ((arg0: string | any) => boolean);
16
- largerThan: ((arg0: string | any) => boolean);
17
- largerThanOrEquals: ((arg0: string | any) => boolean);
18
- };
19
- function contains(array: any[] | any | Function, value: any): boolean;
20
- function containsCaseInsensitive(array: any[] | any | Function, value: any): boolean;
21
- function containsAll(array: any[] | any | Function, values: any[] | any | Function): boolean;
22
- function containsAllCaseInsensitive(array: any[] | any | Function, values: any[] | any | Function): boolean;
23
- function containsAny(array: any[] | any | Function, values: any[] | any | Function): boolean;
24
- function containsAnyCaseInsensitive(array: any[] | any | Function, values: any[] | any | Function): boolean;
25
- function containsNone(array: any[] | any | Function, values: any[] | any | Function): boolean;
26
- function containsNoneCaseInsensitive(array: any[] | any | Function, values: any[] | any | Function): boolean;
27
- function findIndexValue(elements: any[] | any | Function, callback: (value: any, index: any) => boolean | void, optionalSkipHasOwnPropertyCheck?: boolean): {
28
- index: any;
29
- value: any;
30
- } | null;
31
- function findIndex(elements: any[] | any | Function, callback: (value: any, index: any) => boolean | void, optionalSkipHasOwnPropertyCheck?: boolean): any | null;
32
- function find(elements: any[] | any | Function, callback: (value: any, index: any) => boolean | void, optionalSkipHasOwnPropertyCheck?: boolean): any | null;
33
- function getValueAtIndex(elements: any, index: any, optionalSkipHasOwnPropertyCheck?: boolean): any;
34
- function supportsEach(elements: any): boolean;
35
- function eachIterator(elements: any, optionalSkipHasOwnPropertyCheck?: boolean): Generator<any, void, unknown>;
36
- function each(elements: any, callback: (value: any, index?: any) => boolean | void, optionalSkipHasOwnPropertyCheck?: boolean): any;
37
- function eachAsync(elements: any, asyncCallback: any, parallelCount?: number, optionalSkipHasOwnPropertyCheck?: boolean): Promise<any>;
38
- function getEmptySimplifiedCollection(elements: any): [boolean, any[] | any | Map<any, any>, (value: any, index: any) => void];
39
- function filter(elements: any, callback?: (value: any, index: any) => boolean | undefined, optionalSkipHasOwnPropertyCheck?: boolean): any;
40
- function map(elements: any, callback?: (value: any, index: any) => any, optionalSkipHasOwnPropertyCheck?: boolean): any;
41
- function mapToArray(elements: any, callback?: (value: any, index: any) => any, optionalSkipHasOwnPropertyCheck?: boolean): any[];
42
- function mapToArraySorted(elements: any, comparator: (valueA: any, valueB: any) => number, callback?: (value: any, index: any) => any, optionalSkipHasOwnPropertyCheck?: boolean): any[];
43
- function sortKeys(elements: any, comparator: (valueA: any, valueB: any) => number, optionalSkipHasOwnPropertyCheck?: boolean): any[];
44
- function flattenArray(array: any): any[];
45
- function flattenToArray(elements: any, optionalSkipHasOwnPropertyCheck?: boolean): any[];
46
- function compare(a: any, b: any): number;
47
- function compareNumbers(a: number, b: number): number;
48
- function compareNumericStrings(a: string | number, b: string | number): number;
49
- function compareNaturalStrings(a: string, b: string): number;
50
- function compareTimestampStrings(a: string, b: string): number;
51
- function isEmptyObject(obj: any, optionalSkipHasOwnPropertyCheck?: boolean | undefined): boolean;
52
- function getObjectFieldsCount(obj: any, optionalSkipHasOwnPropertyCheck?: boolean | undefined): number;
53
- function isGeneratorFunction(func: any): any;
54
- function setTimeout(callback: (deltaTime: number) => any, ms: number): {
55
- remove: Function;
56
- };
57
- function setInterval(callback: (deltaTime: number) => any, intervalMs?: number, fireImmediately?: boolean): {
58
- remove: Function;
59
- };
60
- function setAnimationFrameTimeout(callback: (deltaTime: number) => any, frames?: number): {
61
- remove: Function;
62
- };
63
- function setAnimationFrameInterval(callback: (deltaTime: number) => any, intervalFrames?: number, fireImmediately?: boolean): {
64
- remove: Function;
65
- };
66
- function promiseTimeout(ms: number): Promise<number>;
67
- function promiseAnimationFrameTimeout(frames: number): Promise<number>;
68
- function fetch(url: string, options?: {
69
- retries?: number | null;
70
- delay?: number | ((attempt: number) => number) | null;
71
- } | any | null): {
72
- then: Function;
73
- catch: Function;
74
- finally: Function;
75
- remove: Function;
76
- isRemoved: Function;
77
- };
78
- function cachedFetch(url: any, options: any, responseFunction: any): Promise<any>;
79
- function platformIsMobile(): boolean;
80
- function platformHasCursor(): boolean;
81
- function capitalize(string: string): string;
82
- function endsWithAny(string: string, endingCharsStringOrArray: string | string[]): boolean;
83
- function startsWithAny(string: string, startingCharsStringOrArray: string | string[]): boolean;
84
- function trimEnd(string: string, trimCharsStringOrArray: string | string[]): string;
85
- function trimStart(string: string, trimCharsStringOrArray: string | string[]): string;
86
- function trim(string: string, trimCharsStringOrArray: string | string[]): string;
87
- function purgeSentence(sentence: string): string;
88
- function purgeErrorMessage(error: any): string;
89
- function generateNamePermutations(...names: string[]): string[];
90
- function increaseNumericStringByOne(string: string): string;
91
- function uniqueId(): string;
92
- function timestamp(now?: number | null | undefined): string;
93
- function getEmptyImageSrc(): string;
94
- function getPercentage(part: number | string, total: number | string): number;
95
- function getImagePixels(image: HTMLImageElement): Uint8ClampedArray;
96
- function getColoredImage(image: HTMLImageElement, color: string): string;
97
- function rgbToHex(rgb: number[]): string;
98
- function hexToRgb(hexstring: string): number[];
99
- function rgbToHsl(rgb: number[]): number[];
100
- function hslToRgb(hsl: any): number[];
101
- function rgbToLab(rgb: number[]): number[];
102
- function getDifferenceBetweenRgb(rgbA: number[], rgbB: number[]): number;
103
- function getDifferenceBetweenLab(labA: number[], labB: number[]): number;
104
- function getRgbOfGradient(gradient: {
105
- percentage?: number[];
106
- }, percentage: number): number[];
107
- function getRgbBetween(startRgb: number[], endRgb: number[], percentage: number): number[];
108
- function btoa(string: string): string;
109
- function atob(base64string: string): string;
110
- function utf8ToBase64(string: string): string;
111
- function base64ToUtf8(base64string: string): string;
112
- function base64ToHex(base64string: string): string;
113
- function hexToBase64(hexstring: string): string;
114
- function base64ToBytes(base64string: string): Uint8Array;
115
- function bytesToBase64(arraybuffer: ArrayLike<number> | ArrayBuffer): string;
116
- function downloadFile(base64string: string, fileName?: string, mimeType?: string): void;
117
- function localStorageGet(id: string): any;
118
- function localStorageSet(id: string, data: any): void;
119
- function localStorageRemove(id: string): void;
120
- function isCurrentHostPrivate(): boolean;
121
- function isGivenHostPrivate(host: string): boolean;
122
- function createTransactionalValue(value?: any): {
123
- value: any;
124
- changes: {
125
- id: string;
126
- value: any;
127
- }[];
128
- };
129
- function isTransactionalValueValid(transactionalValue: {
130
- value: any;
131
- changes: {
132
- id: string;
133
- value: any;
134
- }[];
135
- }): boolean;
136
- function transactionalValueToString(transactionalValue: {
137
- value: any;
138
- changes: {
139
- id: string;
140
- value: any;
141
- }[];
142
- }): string;
143
- function transactionSetAndCommit(transactionalValue: {
144
- value: any;
145
- changes: {
146
- id: string;
147
- value: any;
148
- }[];
149
- }, value: any): void;
150
- function transactionSetWithoutCommitting(transactionalValue: {
151
- value: any;
152
- changes: {
153
- id: string;
154
- value: any;
155
- }[];
156
- }, value: any): string;
157
- function transactionCommitChange(transactionalValue: {
158
- value: any;
159
- changes: {
160
- id: string;
161
- value: any;
162
- }[];
163
- }, changeId: string): boolean;
164
- function transactionCancelChange(transactionalValue: {
165
- value: any;
166
- changes: {
167
- id: string;
168
- value: any;
169
- }[];
170
- }, changeId: string): boolean;
171
- function transactionIsChangeRelevant(transactionalValue: {
172
- value: any;
173
- changes: {
174
- id: string;
175
- value: any;
176
- }[];
177
- }, changeId: string): boolean;
178
- function transactionGetCommittedValue(transactionalValue: {
179
- value: any;
180
- changes: {
181
- id: string;
182
- value: any;
183
- }[];
184
- }): any;
185
- function transactionGetValue(transactionalValue: {
186
- value: any;
187
- changes: {
188
- id: string;
189
- value: any;
190
- }[];
191
- }): any;
192
- function createWorkerThread(name: string): {
193
- worker: Worker | null;
194
- sendMessage: (data: any, options: {
195
- timeout: number | undefined;
196
- } | undefined) => Promise<any>;
197
- };
198
- function sendWorkerMessage(workerName: any, data: any, options: any): any;
199
- function purgeEmail(email: string): string;
200
- function isFocusClear(): boolean;
201
- function getUserLocale(): any;
202
- function getUserLocaleDateFormat(): any;
203
- }
@@ -1,46 +0,0 @@
1
- /**
2
- * A simple event emitter class that allows you to register listeners for events, emit events, and remove listeners.
3
- */
4
- export class EventEmitter {
5
- /**
6
- * Registers a listener for a specific event.
7
- *
8
- * @param {string} event - The name of the event to listen for.
9
- * @param {Function} listener - The function to call when the event is emitted.
10
- * @returns {{remove:(()=>void)}}
11
- */
12
- on(event: string, listener: Function): {
13
- remove: (() => void);
14
- };
15
- /**
16
- * Registers a listener for a specific event, this listener will be called only once.
17
- *
18
- * @param {string} event - The name of the event to listen for.
19
- * @param {Function} listener - The function to call when the event is emitted.
20
- * @returns {{remove:()=>void}}
21
- */
22
- once(event: string, listener: Function): {
23
- remove: () => void;
24
- };
25
- /**
26
- * Removes a listener for a specific event.
27
- *
28
- * @param {string} event - The name of the event to stop listening for.
29
- * @param {Function} listener - The function to remove from the event listeners.
30
- */
31
- off(event: string, listener: Function): void;
32
- /**
33
- * Emits an event, calling all registered listeners with the provided arguments.
34
- *
35
- * @param {string} event - The name of the event to emit.
36
- * @param {...*} args - The arguments to pass to the listeners.
37
- */
38
- emit(event: string, ...args: any[]): void;
39
- /**
40
- * Clears all listeners for a specific event or all events if no event is specified.
41
- *
42
- * @param {string} [event] - The name of the event to clear listeners for. If not provided, all events will be cleared.
43
- */
44
- clear(event?: string): void;
45
- #private;
46
- }
@@ -1,33 +0,0 @@
1
- export class LinkedList {
2
- /**
3
- * Returns the number of elements in the list.
4
- *
5
- * @returns {number}
6
- */
7
- get size(): number;
8
- /**
9
- * Adds a new value to the beginning of the list.
10
- *
11
- * @param {*} value
12
- */
13
- unshift(value: any): void;
14
- /**
15
- * Adds a new value to the end of the list.
16
- *
17
- * @param {*} value
18
- */
19
- push(value: any): void;
20
- /**
21
- * Removes the first value from the list and returns it.
22
- *
23
- * @returns {*|undefined}
24
- */
25
- shift(): any | undefined;
26
- /**
27
- * Removes the last value from the list and returns it.
28
- *
29
- * @returns {*|undefined}
30
- */
31
- pop(): any | undefined;
32
- #private;
33
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * SerializableMap class extends the native Map to provide a JSON representation.
3
- *
4
- * This class can only have string keys, as JSON does not support non-string keys.
5
- */
6
- export class SerializableMap extends Map<any, any> {
7
- constructor();
8
- constructor(entries?: readonly (readonly [any, any])[] | null | undefined);
9
- constructor();
10
- constructor(iterable?: Iterable<readonly [any, any]> | null | undefined);
11
- /**
12
- * Returns a JSON representation of the map.
13
- *
14
- * @returns {Object}
15
- */
16
- toJSON(): any;
17
- }
@@ -1,115 +0,0 @@
1
- /**
2
- * A TreeSet is a set of elements, sorted by a comparator.
3
- * Binary search is used to find elements, which makes it very fast to find elements.
4
- *
5
- * The comparator is also used to determine if two values are equal to each other.
6
- * This way, you can have values that aren't the same be treated as if they are. This can be used to deal with issues such as floating point errors for example.
7
- */
8
- export class TreeSet {
9
- /**
10
- * Creates a new TreeSet with the given elements and comparator.
11
- *
12
- * @param {*[]} [elements=[]] - The initial elements of the set.
13
- * @param {(valueA:*, valueB:*) => number} [comparator=LeUtils.compare] - The comparator function to use for sorting.
14
- */
15
- constructor(elements?: any[], comparator?: (valueA: any, valueB: any) => number);
16
- /**
17
- *
18
- *
19
- * @param {*} value - The value to search for in the set.
20
- * @returns {{found:boolean, index:number, value:*|undefined}} - An object containing whether the value was found, the index where it would be inserted, and the value at that index (if found).
21
- * @private
22
- */
23
- private binarySearch;
24
- /**
25
- * Returns the elements of the set.
26
- */
27
- getElements(): any[];
28
- /**
29
- * Returns the comparator of the set.
30
- *
31
- * @returns {(valueA:*, valueB:*) => number}
32
- */
33
- getComparator(): (valueA: any, valueB: any) => number;
34
- /**
35
- * Returns the size of the set.
36
- *
37
- * @returns {number}
38
- */
39
- size(): number;
40
- /**
41
- * Returns true if the set is empty, false otherwise.
42
- *
43
- * @returns {boolean}
44
- */
45
- isEmpty(): boolean;
46
- /**
47
- * Returns true if the set contains a value that is equal to the given value, returns false otherwise.
48
- *
49
- * @param {*} value - The value to check for in the set.
50
- * @return {boolean} - True if the set contains the value, false otherwise.
51
- */
52
- contains(value: any): boolean;
53
- /**
54
- * Returns the first element of the set, or undefined if it is empty.
55
- *
56
- * @return {*|undefined} - The first element of the set, or undefined if it is empty.
57
- */
58
- first(): any | undefined;
59
- /**
60
- * Returns the last element of the set, or undefined if it is empty.
61
- *
62
- * @return {*|undefined} - The last element of the set, or undefined if it is empty.
63
- */
64
- last(): any | undefined;
65
- /**
66
- * Removes and returns the first element of the set, or undefined if it is empty.
67
- *
68
- * @returns {*|undefined} - The first element of the set, or undefined if it is empty.
69
- */
70
- pollFirst(): any | undefined;
71
- /**
72
- * Removes and returns the last element of the set, or undefined if it is empty.
73
- *
74
- * @returns {*|undefined} - The last element of the set, or undefined if it is empty.
75
- */
76
- pollLast(): any | undefined;
77
- /**
78
- * Adds the given value to the set. Will only do so if no equal value already exists.
79
- * @param {*} value - The value to add to the set.
80
- */
81
- add(value: any): void;
82
- /**
83
- * Adds all the given values to the set. Will only do so if no equal value already exists.
84
- *
85
- * @param {*} values - The values to add to the set.
86
- */
87
- addAll(values: any): void;
88
- /**
89
- * Returns an equal value that's already in the tree set, or undefined if no equal values in it exist.
90
- *
91
- * @param {*} value - The value to search for in the set.
92
- * @return {*|undefined} - The equal value if found, or undefined if not found.
93
- */
94
- getEqualValue(value: any): any | undefined;
95
- /**
96
- * Returns an equal value that's already in the tree set. If no equal values in it exist, the given value will be added and returned.
97
- *
98
- * @param {*} value - The value to search for in the set.
99
- * @return {*} - The equal value if found, or the added value if not found.
100
- */
101
- getEqualValueOrAdd(value: any): any;
102
- /**
103
- * Returns a string representation of the TreeSet.
104
- *
105
- * @returns {string} - A string representation of the TreeSet, including its elements and comparator.
106
- */
107
- toString(): string;
108
- /**
109
- * Returns a JSON representation of the TreeSet.
110
- *
111
- * @returns {Object} - An object containing the elements and comparator of the TreeSet.
112
- */
113
- toJSON(): any;
114
- #private;
115
- }
package/build/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export { LeUtils } from "./LeUtils.js";
2
- export { EventEmitter } from "./classes/EventEmitter.js";
3
- export { LinkedList } from "./classes/LinkedList.js";
4
- export { SerializableMap } from "./classes/SerializableMap.js";
5
- export { TreeSet } from "./classes/TreeSet.js";
6
- export { ISSET, IS_ARRAY, ARRAY, IS_OBJECT, OBJECT, STRING, STRING_ANY, INT, INT_ANY, FLOAT, FLOAT_ANY, INT_LAX, INT_LAX_ANY, FLOAT_LAX, FLOAT_LAX_ANY } from "./LeTypes.js";