@3dsource/utils 1.0.19 → 1.0.21

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.
Files changed (92) hide show
  1. package/LICENSE +14 -14
  2. package/README.md +149 -46
  3. package/fesm2022/3dsource-utils.mjs +75 -50
  4. package/fesm2022/3dsource-utils.mjs.map +1 -1
  5. package/index.d.ts +863 -3
  6. package/package.json +2 -2
  7. package/lib/color/CMYKtoRGB.d.ts +0 -10
  8. package/lib/color/HEXtoRGB.d.ts +0 -5
  9. package/lib/color/HSVtoRGB.d.ts +0 -21
  10. package/lib/color/RGBtoCMYK.d.ts +0 -20
  11. package/lib/color/RGBtoHEX.d.ts +0 -1
  12. package/lib/color/RGBtoHSV.d.ts +0 -19
  13. package/lib/color/hsv.d.ts +0 -1
  14. package/lib/color/index.d.ts +0 -16
  15. package/lib/color/max.d.ts +0 -1
  16. package/lib/color/min.d.ts +0 -1
  17. package/lib/color/overlay.d.ts +0 -1
  18. package/lib/color/rgb.d.ts +0 -8
  19. package/lib/color/sub.d.ts +0 -1
  20. package/lib/color/subtract.d.ts +0 -1
  21. package/lib/color/sum.d.ts +0 -1
  22. package/lib/color/toRGB.d.ts +0 -8
  23. package/lib/color/toRGBA.d.ts +0 -1
  24. package/lib/constants/color-codes.constant.d.ts +0 -9
  25. package/lib/constants/index.d.ts +0 -1
  26. package/lib/csv/CSV2Array.d.ts +0 -1
  27. package/lib/csv/CSV2Records.d.ts +0 -1
  28. package/lib/csv/ObjectToCSV.d.ts +0 -1
  29. package/lib/csv/index.d.ts +0 -3
  30. package/lib/dev/dev3d.d.ts +0 -1
  31. package/lib/dev/index.d.ts +0 -3
  32. package/lib/dev/logger.d.ts +0 -11
  33. package/lib/dev/timeToString.d.ts +0 -5
  34. package/lib/filenaming/cleanupFileName.d.ts +0 -1
  35. package/lib/filenaming/index.d.ts +0 -3
  36. package/lib/filenaming/makePath.d.ts +0 -1
  37. package/lib/filenaming/normalizePath.d.ts +0 -1
  38. package/lib/geom/expandOverRectangle.d.ts +0 -2
  39. package/lib/geom/fitIntoRectangle.d.ts +0 -2
  40. package/lib/geom/index.d.ts +0 -3
  41. package/lib/geom/interfaces/area.interface.d.ts +0 -4
  42. package/lib/geom/interfaces/index.d.ts +0 -4
  43. package/lib/geom/interfaces/rect.interface.d.ts +0 -4
  44. package/lib/geom/interfaces/size.interface.d.ts +0 -4
  45. package/lib/geom/interfaces//321/201oords.interface.d.ts +0 -4
  46. package/lib/helpers/BatchLoader.d.ts +0 -47
  47. package/lib/helpers/KeyboardNumericCode.d.ts +0 -103
  48. package/lib/helpers/debounce.d.ts +0 -1
  49. package/lib/helpers/generate-uuid.d.ts +0 -1
  50. package/lib/helpers/index.d.ts +0 -12
  51. package/lib/helpers/is-desktop.d.ts +0 -1
  52. package/lib/helpers/media.d.ts +0 -1
  53. package/lib/helpers/save-to-local-drive.d.ts +0 -1
  54. package/lib/helpers/serialize.d.ts +0 -1
  55. package/lib/helpers/short-hash.d.ts +0 -2
  56. package/lib/helpers/signal.d.ts +0 -23
  57. package/lib/helpers/sleep.d.ts +0 -1
  58. package/lib/helpers/trimLastSlashFromUrl.d.ts +0 -1
  59. package/lib/image/SaveImage.d.ts +0 -18
  60. package/lib/image/getCanvasCached.d.ts +0 -4
  61. package/lib/image/getSnapshot.d.ts +0 -2
  62. package/lib/image/index.d.ts +0 -4
  63. package/lib/image/loadImage.d.ts +0 -1
  64. package/lib/interfaces/image-output.d.ts +0 -7
  65. package/lib/interfaces/index.d.ts +0 -3
  66. package/lib/interfaces/load-args-tmp.interface.d.ts +0 -4
  67. package/lib/interfaces/load-args.interface.d.ts +0 -15
  68. package/lib/math/baseSortedIndex.d.ts +0 -25
  69. package/lib/math/calculateMedian.d.ts +0 -17
  70. package/lib/math/circularIndex.d.ts +0 -35
  71. package/lib/math/clampf.d.ts +0 -8
  72. package/lib/math/degrees.d.ts +0 -2
  73. package/lib/math/floatCompare.d.ts +0 -42
  74. package/lib/math/index.d.ts +0 -8
  75. package/lib/math/inverseLerp.d.ts +0 -17
  76. package/lib/math/lerp.d.ts +0 -7
  77. package/lib/mutex/Mutex.d.ts +0 -43
  78. package/lib/mutex/Semaphore.d.ts +0 -42
  79. package/lib/mutex/TaskRunner.d.ts +0 -5
  80. package/lib/mutex/index.d.ts +0 -3
  81. package/lib/predicates/index.d.ts +0 -3
  82. package/lib/predicates/operators.d.ts +0 -32
  83. package/lib/predicates/textForSearch.d.ts +0 -18
  84. package/lib/predicates/where.d.ts +0 -46
  85. package/lib/rxjs/index.d.ts +0 -3
  86. package/lib/rxjs/leadingTrailingDebounceTime.d.ts +0 -15
  87. package/lib/rxjs/smoothTransition.d.ts +0 -11
  88. package/lib/rxjs/tapLog.d.ts +0 -2
  89. package/lib/strings/index.d.ts +0 -1
  90. package/lib/strings/pad.d.ts +0 -8
  91. package/lib/tokens/index.d.ts +0 -3
  92. package/public-api.d.ts +0 -15
@@ -1,35 +0,0 @@
1
- /**
2
- * Computes a circular index within a given range.
3
- *
4
- * This function ensures that the index wraps around within the range of 0 to `totalItems - 1`.
5
- * It uses the `clampf` function to clamp the result within the valid range.
6
- *
7
- * @param index - The current index to be wrapped.
8
- * @param totalItems - The total number of items in the range.
9
- * @returns The wrapped index within the range of 0 to `totalItems - 1`.
10
- *
11
- * @example
12
- * ```typescript
13
- * import { circularIndex } from './circularIndex';
14
- *
15
- * // Example 1: Basic usage
16
- * const index1 = circularIndex(5, 5);
17
- * console.log(index1); // Output: 0
18
- *
19
- * // Example 2: Index greater than totalItems
20
- * const index2 = circularIndex(6, 5);
21
- * console.log(index2); // Output: 1
22
- *
23
- * // Example 3: Negative index
24
- * const index3 = circularIndex(-2, 5);
25
- * console.log(index3); // Output: 3
26
- *
27
- * // Example 4: Large Negative index
28
- * const index4 = circularIndex(-6, 5);
29
- * console.log(index4); // Output: 4
30
- *
31
- * // Example 5: Index equal to totalItems
32
- * const index5 = circularIndex(1, 1);
33
- * console.log(index5); // Output: 0
34
- */
35
- export declare function circularIndex(index: number, totalItems: number): number;
@@ -1,8 +0,0 @@
1
- /**
2
- * Clamps value between min and max;
3
- * @param min minValue
4
- * @param max maxValue
5
- * @param value inputValue
6
- * @returns number
7
- */
8
- export declare function clampf(min: number, max: number, value: number): number;
@@ -1,2 +0,0 @@
1
- export declare function degreesToRadians(degrees: number): number;
2
- export declare function radiansToDegrees(radians: number): number;
@@ -1,42 +0,0 @@
1
- /**
2
- * Checks if floating-point number `A` is less than `B` considering a small margin of error.
3
- *
4
- * @param A - The first floating-point number to compare.
5
- * @param B - The second floating-point number to compare.
6
- * @param Epsilon - Optional custom epsilon value for comparison. Defaults to `EPSILON` if not provided.
7
- * @returns `true` if `A` is less than `B` considering the epsilon margin, otherwise `false`.
8
- *
9
- * @example
10
- * ```
11
- * const result = fpIsALessThanB(0.0034, 0.0066); // true
12
- * ```
13
- */
14
- export declare function fpIsALessThanB(A: number, B: number, Epsilon?: number): boolean;
15
- /**
16
- * Checks if floating-point number `A` is greater than `B` considering a small margin of error.
17
- *
18
- * @param A - The first floating-point number to compare.
19
- * @param B - The second floating-point number to compare.
20
- * @param Epsilon - Optional custom epsilon value for comparison. Defaults to `EPSILON` if not provided.
21
- * @returns `true` if `A` is greater than `B` considering the epsilon margin, otherwise `false`.
22
- *
23
- * @example
24
- * ```
25
- * const result = fpIsAGreaterThanB(0.0066, 0.0034); // true
26
- * ```
27
- */
28
- export declare function fpIsAGreaterThanB(A: number, B: number, Epsilon?: number): boolean;
29
- /**
30
- * Checks if floating-point number `A` is approximately the same as `B` considering a small margin of error.
31
- *
32
- * @param A - The first floating-point number to compare.
33
- * @param B - The second floating-point number to compare.
34
- * @param Epsilon - Optional custom epsilon value for comparison. Defaults to `EPSILON` if not provided.
35
- * @returns `true` if `A` is approximately equal to `B` considering the epsilon margin, otherwise `false`.
36
- *
37
- * @example
38
- * ```
39
- * const result = fpIsASameAsB(0.005, 0.0051); // true
40
- * ```
41
- */
42
- export declare function fpIsASameAsB(A: number, B: number, Epsilon?: number): boolean;
@@ -1,8 +0,0 @@
1
- export * from './baseSortedIndex';
2
- export * from './calculateMedian';
3
- export * from './circularIndex';
4
- export * from './clampf';
5
- export * from './degrees';
6
- export * from './floatCompare';
7
- export * from './inverseLerp';
8
- export * from './lerp';
@@ -1,17 +0,0 @@
1
- /**
2
- * Performs an inverse linear interpolation.
3
- *
4
- * Given a range defined by `min` and `max`, this function calculates the
5
- * interpolation factor (or percentage) of `value` within that range. Optionally,
6
- * it can clamp the result to be between 0 and 1 to ensure the return value is
7
- * within the range of a standard lerp operation.
8
- *
9
- * @param {number} min - The minimum value of the interpolation range.
10
- * @param {number} max - The maximum value of the interpolation range.
11
- * @param {number} value - The value to interpolate.
12
- * @param {boolean} [clampToNormal=false] - Whether to clamp the result between 0 and 1.
13
- * @returns {number} The interpolation factor of `value` between `min` and `max`.
14
- * If `clampToNormal` is true, the result is clamped between 0 and 1.
15
- * If the difference between `min` and `max` is 0, returns 1 to avoid division by zero.
16
- */
17
- export declare function inverseLerp(min: number, max: number, value: number, clampToNormal?: boolean): number;
@@ -1,7 +0,0 @@
1
- /**
2
- * @param min minimums
3
- * @param max maximums
4
- * @param value current float value in 0-1 range
5
- * @returns clamped value
6
- */
7
- export declare function lerp(min: number, max: number, value: number): number;
@@ -1,43 +0,0 @@
1
- /**
2
- * A Mutex class to handle mutual exclusion locks, ensuring that only one asynchronous task can execute a critical section at a time.
3
- *
4
- * @example
5
- * const mutex = new Mutex();
6
- *
7
- * async function task(name: string, duration: number) {
8
- * console.log(`${name} waiting to acquire mutex`);
9
- * const release = await mutex.acquire();
10
- * console.log(`${name} acquired mutex`);
11
- * await new Promise(resolve => setTimeout(resolve, duration));
12
- * console.log(`${name} releasing mutex`);
13
- * release();
14
- * }
15
- *
16
- * task('Task 1', 1000);
17
- * task('Task 2', 2000);
18
- * task('Task 3', 1500);
19
- * task('Task 4', 500);
20
- *
21
- * Outputs
22
- * [LOG]: "Task 1 waiting to acquire mutex"
23
- * [LOG]: "Task 2 waiting to acquire mutex"
24
- * [LOG]: "Task 3 waiting to acquire mutex"
25
- * [LOG]: "Task 4 waiting to acquire mutex"
26
- * [LOG]: "Task 1 acquired mutex"
27
- * [LOG]: "Task 1 releasing mutex"
28
- * [LOG]: "Task 2 acquired mutex"
29
- * [LOG]: "Task 2 releasing mutex"
30
- * [LOG]: "Task 3 acquired mutex"
31
- * [LOG]: "Task 3 releasing mutex"
32
- * [LOG]: "Task 4 acquired mutex"
33
- * [LOG]: "Task 4 releasing mutex"
34
- */
35
- export declare class Mutex {
36
- private mutex;
37
- /**
38
- * Acquires the mutex, returning a promise that resolves when the mutex is acquired.
39
- * The returned promise provides a release function that should be called to release the mutex.
40
- * @returns A promise that resolves with a release function.
41
- */
42
- acquire(): Promise<() => void>;
43
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * A Semaphore controls access to a resource that can handle a limited number of concurrent operations.
3
- *
4
- * @example
5
- * const semaphore = new Semaphore(2);
6
- *
7
- * async function task(name: string, duration: number) {
8
- * console.log(`${name} waiting to acquire semaphore`);
9
- * await semaphore.acquire();
10
- * console.log(`${name} acquired semaphore`);
11
- * await new Promise(resolve => setTimeout(resolve, duration));
12
- * console.log(`${name} releasing semaphore`);
13
- * semaphore.release();
14
- * }
15
- *
16
- * task('Task 1', 1000);
17
- * task('Task 2', 2000);
18
- * task('Task 3', 1500);
19
- * task('Task 4', 500);
20
- *
21
- * Outputs
22
- * [LOG]: "Task 1 waiting to acquire semaphore"
23
- * [LOG]: "Task 2 waiting to acquire semaphore"
24
- * [LOG]: "Task 3 waiting to acquire semaphore"
25
- * [LOG]: "Task 4 waiting to acquire semaphore"
26
- * [LOG]: "Task 1 acquired semaphore"
27
- * [LOG]: "Task 2 acquired semaphore"
28
- * [LOG]: "Task 1 releasing semaphore"
29
- * [LOG]: "Task 3 acquired semaphore"
30
- * [LOG]: "Task 2 releasing semaphore"
31
- * [LOG]: "Task 4 acquired semaphore"
32
- * [LOG]: "Task 4 releasing semaphore"
33
- * [LOG]: "Task 3 releasing semaphore"
34
- */
35
- export declare class Semaphore {
36
- private readonly maxConcurrency;
37
- private tasks;
38
- private currentCount;
39
- constructor(maxConcurrency: number);
40
- acquire(): Promise<void>;
41
- release(): void;
42
- }
@@ -1,5 +0,0 @@
1
- import type { Observable } from 'rxjs';
2
- export declare class TaskRunner {
3
- private mutex;
4
- runTask(name: string, task: () => Observable<string | null>): Observable<string | null>;
5
- }
@@ -1,3 +0,0 @@
1
- export * from './Mutex';
2
- export * from './Semaphore';
3
- export * from './TaskRunner';
@@ -1,3 +0,0 @@
1
- export * from './operators';
2
- export * from './textForSearch';
3
- export * from './where';
@@ -1,32 +0,0 @@
1
- type TruthyTypesOf<T> = T extends false | '' | 0 | null | undefined ? never : T;
2
- type FalsyTypesOf<T> = T extends false | '' | 0 | null | undefined ? T : never;
3
- type EmptyTypesOf<T> = T extends undefined | null | object | '' ? T : never;
4
- type NonEmptyTypesOf<T> = T extends undefined | null | object | '' ? never : T;
5
- /**
6
- * The Boolean object represents a truth value: true or false.
7
- * @param value
8
- * @constructor
9
- * Returns:boolean
10
- */
11
- export declare const Truthy: <T>(value: T) => value is TruthyTypesOf<T>;
12
- /**
13
- * The Boolean object represents an INVERSE truth value: true or false.
14
- * @param value
15
- * @constructor
16
- * Returns:boolean
17
- */
18
- export declare const Falsy: <T>(value: T) => value is FalsyTypesOf<T>;
19
- /**
20
- * Checks if a value is empty.
21
- *
22
- * @param {any} value - The value to check.
23
- * @return {boolean} Returns true if the value is empty, otherwise false.
24
- */
25
- export declare const IsEmpty: <T>(value: T) => value is EmptyTypesOf<T>;
26
- export declare const NotEmpty: <T>(value: T) => value is NonEmptyTypesOf<T>;
27
- export declare const isDefined: <T>(arg: T | null | undefined) => arg is T;
28
- export declare const isNotDefined: <T>(arg: T | null | undefined) => arg is null | undefined;
29
- export declare const isJSON: (str: string) => boolean;
30
- export declare const isEmpty: (value: any) => boolean;
31
- export declare function isAllValuesTruthy<T extends string, K>(value: Record<T, K>): boolean;
32
- export {};
@@ -1,18 +0,0 @@
1
- /**
2
- * Converts a given value to a string suitable for search comparisons.
3
- * The resulting string is in lowercase, with consecutive spaces replaced by underscores.
4
- * The function uses a cache to improve performance by storing and reusing the results of previous conversions.
5
- *
6
- * @param {any} value - The value to be converted to a search-friendly string.
7
- * It can be of any type, but it will be coerced to a string if not already one.
8
- *
9
- * @param {boolean} caseSensitive - A flag indicating whether the comparison should be case-sensitive.
10
- * If set to true, the function will perform case-sensitive comparisons, preserving the original casing of input strings.
11
- * If set to false (default), the function will convert the input strings to lowercase for case-insensitive comparisons
12
- *
13
- * @returns {string} The processed string, which is trimmed, converted to lowercase (unless caseSensitive is true),
14
- * and has all sequences of spaces replaced with underscores. This string is either
15
- * retrieved from the cache or freshly computed and then cached.
16
- *
17
- */
18
- export declare function textForSearch(value: unknown, caseSensitive?: boolean): string;
@@ -1,46 +0,0 @@
1
- import type { TruthyTypesOf } from 'rxjs';
2
- /**
3
- * Creates a predicate function to filter records from a collection based on specified criteria.
4
- *
5
- * The `where` function accepts a criteria object with key-value pairs, indicating the fields
6
- * and their expected values for filtering. It returns a predicate function that filters a collection
7
- * of records. This predicate checks if records match the criteria using a case-insensitive comparison,
8
- * making it particularly useful in conjunction with the `textForSearch` function, which standardizes
9
- * strings for such comparisons.
10
- *
11
- * Each criterion value is first processed with `textForSearch` to normalize spacing and case,
12
- * ensuring consistent and predictable filtering. The comparison between each record's field value
13
- * and the criterion value is thus case-insensitive and ignores extra spaces.
14
- *
15
- * @param {Partial<Record<K, T[K]>>} criteria - An object representing the filtering criteria.
16
- * Keys correspond to the record's fields to be filtered, and values are the expected values for those fields,
17
- * processed in a case-insensitive manner. Undefined values are ignored.
18
- *
19
- * @param {boolean} caseSensitive - A flag indicating whether the comparison should be case-sensitive.
20
- * If set to true, the function will perform case-sensitive comparisons, preserving the original casing of input strings.
21
- * If set to false (default), the function will convert the input strings to lowercase for case-insensitive comparisons
22
- *
23
- * @returns {(record: T) => boolean} A predicate function that takes a record of type `T`
24
- * and returns `true` if the record's field values match all criteria, otherwise `false`.
25
- *
26
- * @example
27
- * // Define a collection of items
28
- * const items = [
29
- * { name: "Apple", category: "Fruit" },
30
- * { name: "Carrot", category: "Vegetable" },
31
- * { name: "Banana", category: "Fruit" }
32
- * ];
33
- *
34
- * // Create a predicate to find fruits, using a case-insensitive comparison
35
- * const isFruit = where({ category: "fruit" }); // 'fruit' will match 'Fruit' in items
36
- *
37
- * // Filter the collection with the predicate
38
- * const fruits = items.filter(isFruit);
39
- * // Output: [{ name: "Apple", category: "Fruit" }, { name: "Banana", category: "Fruit" }]
40
- *
41
- * @typeparam T - Specifies the type of records in the collection to be filtered. It extends `object`,
42
- * ensuring the function is only used with object types. This generic approach allows for flexible usage
43
- * with various record structures.
44
- */
45
- export declare function where<T extends object>(criteria: Partial<TruthyTypesOf<T>>, caseSensitive?: boolean): (record: T) => boolean;
46
- export declare function whereNot<T extends object>(criteria: Partial<TruthyTypesOf<T>>, caseSensitive?: boolean): (record: T) => boolean;
@@ -1,3 +0,0 @@
1
- export * from './leadingTrailingDebounceTime';
2
- export * from './smoothTransition';
3
- export * from './tapLog';
@@ -1,15 +0,0 @@
1
- import type { SchedulerLike } from 'rxjs';
2
- import { Observable } from 'rxjs';
3
- /**
4
- * Emits the most recent value emitted by the source Observable after a
5
- * specified time span has passed without another source emission.
6
- *
7
- * This is a combination of `debounceTime` and `auditTime` operators.
8
- *
9
- * The leading value is emitted immediately, and trailing values are debounced.
10
- *
11
- * @param dueTime The time to wait before emitting the last value.
12
- * @param scheduler The scheduler to use for the timeout.
13
- * @returns A function that returns an Observable that mirrors the source Observable, but applies the specified debouncing.
14
- */
15
- export declare function leadingTrailingDebounceTime<T>(dueTime: number, scheduler?: SchedulerLike): (source: Observable<T>) => Observable<T>;
@@ -1,11 +0,0 @@
1
- import type { Observable } from 'rxjs';
2
- /**
3
- * Creates an observable that emits values transitioning smoothly from the start value to the end value over a specified duration.
4
- * The transition is performed using linear interpolation (lerp) and clamped to the range [0, 1].
5
- *
6
- * @param {number} start - The starting value of the transition.
7
- * @param {number} end - The ending value of the transition.
8
- * @param {number} duration - The duration of the transition in milliseconds.
9
- * @returns {Observable<number>} An observable that emits the interpolated values from start to end over the specified duration.
10
- */
11
- export declare const smoothTransition: (start: number, end: number, duration: number) => Observable<number>;
@@ -1,2 +0,0 @@
1
- import type { Observable } from 'rxjs';
2
- export declare const tapLog: <T>(text: string, ...args: any) => ((source: Observable<T>) => Observable<T>);
@@ -1 +0,0 @@
1
- export * from './pad';
@@ -1,8 +0,0 @@
1
- /**
2
- * Adds required number of symbols before input
3
- * @param input input string
4
- * @param size amount of total symbols
5
- * @param symbol filler
6
- * @returns string
7
- */
8
- export declare function pad(input: number | string, size: number, symbol?: string): string;
@@ -1,3 +0,0 @@
1
- import { InjectionToken } from '@angular/core';
2
- export declare const WINDOW: InjectionToken<Window>;
3
- export declare const DOCUMENT_ROOT: InjectionToken<string>;
package/public-api.d.ts DELETED
@@ -1,15 +0,0 @@
1
- export * from './lib/color';
2
- export * from './lib/constants';
3
- export * from './lib/csv';
4
- export * from './lib/dev';
5
- export * from './lib/filenaming';
6
- export * from './lib/geom';
7
- export * from './lib/helpers';
8
- export * from './lib/image';
9
- export * from './lib/interfaces';
10
- export * from './lib/math';
11
- export * from './lib/mutex';
12
- export * from './lib/predicates';
13
- export * from './lib/rxjs';
14
- export * from './lib/strings';
15
- export * from './lib/tokens';