@trackunit/shared-utils 1.5.140 → 1.5.141
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 +2 -2
- package/src/GroupingUtility.d.ts +1 -1
- package/src/arrayUtils.d.ts +3 -3
- package/src/deepPartial.d.ts +2 -2
- package/src/fastArrayOperations.d.ts +2 -2
- package/src/filter.d.ts +2 -2
- package/src/groupBy/groupBy.d.ts +1 -1
- package/src/idUtils.d.ts +1 -1
- package/src/objectUtils.d.ts +2 -2
- package/src/sorting/sorting.d.ts +1 -1
- package/src/svgTools.d.ts +2 -2
- package/src/typeUtils.d.ts +6 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/shared-utils",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.141",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.x"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"uuid": "^11.1.0",
|
|
11
|
-
"@trackunit/react-test-setup": "1.0.
|
|
11
|
+
"@trackunit/react-test-setup": "1.0.31"
|
|
12
12
|
},
|
|
13
13
|
"module": "./index.esm.js",
|
|
14
14
|
"main": "./index.cjs.js",
|
package/src/GroupingUtility.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ export interface GroupingUtilityData {
|
|
|
10
10
|
* @param smallestCount Breaking point to start considering the item as candidate to "Others" group [in percentage] - default 0,5%
|
|
11
11
|
* @param limitToStartGrouping Lowest limit of candidates for grouping to "Others" [in percentage] - default 3%
|
|
12
12
|
*/
|
|
13
|
-
export declare function groupTinyDataToOthers(data: GroupingUtilityData
|
|
13
|
+
export declare function groupTinyDataToOthers(data: Array<GroupingUtilityData> | undefined, smallestCount?: number, limitToStartGrouping?: number): Array<GroupingUtilityData> | undefined;
|
package/src/arrayUtils.d.ts
CHANGED
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
* @param newArray The new array of items to merge with the previous array
|
|
7
7
|
* @returns A new array with the items from the previous array and the new array, but only if the item's key is unique.
|
|
8
8
|
*/
|
|
9
|
-
export declare const unionArraysByKey: <TObject extends object>(key: keyof TObject, previous: TObject
|
|
9
|
+
export declare const unionArraysByKey: <TObject extends object>(key: keyof TObject, previous: Array<TObject> | undefined | null, newArray: Array<TObject> | undefined | null) => Array<TObject>;
|
|
10
10
|
/**
|
|
11
11
|
* Checks if two arrays are equal.
|
|
12
12
|
*/
|
|
13
|
-
export declare const isArrayEqual: <TItem extends string | number>(a: TItem
|
|
13
|
+
export declare const isArrayEqual: <TItem extends string | number>(a: Array<TItem>, b: Array<TItem>) => boolean;
|
|
14
14
|
/**
|
|
15
15
|
* Checks if an array is not empty.
|
|
16
16
|
*
|
|
17
17
|
* @param array - The array to check.
|
|
18
18
|
* @returns The array if not empty, otherwise undefined.
|
|
19
19
|
*/
|
|
20
|
-
export declare const arrayNotEmpty: <TItem>(array?: TItem
|
|
20
|
+
export declare const arrayNotEmpty: <TItem>(array?: Array<TItem>) => Array<TItem> | undefined;
|
package/src/deepPartial.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type DeepPartialNullable<T> = T extends any
|
|
1
|
+
export type DeepPartialNullable<T> = T extends Array<any> ? DeepPartialNullableArray<T[number]> : T extends object ? {
|
|
2
2
|
[P in keyof T]?: DeepPartialNullable<T[P]> | null;
|
|
3
3
|
} : T | null;
|
|
4
|
-
export type DeepPartialNullableArray<T> = DeepPartialNullable<T
|
|
4
|
+
export type DeepPartialNullableArray<T> = Array<DeepPartialNullable<T>>;
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* @param arr2 An array of string or numbers
|
|
5
5
|
* @returns The elements shared between arr1 and arr2.
|
|
6
6
|
*/
|
|
7
|
-
export declare function intersection<T>(arr1: T
|
|
7
|
+
export declare function intersection<T>(arr1: Array<T>, arr2: Array<T>): Array<T>;
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
* @param arr1 An array of string or numbers
|
|
11
11
|
* @param arr2 An array of string or numbers
|
|
12
12
|
* @returns The elements present in arr1 but not arr2.
|
|
13
13
|
*/
|
|
14
|
-
export declare function difference<T>(arr1: T
|
|
14
|
+
export declare function difference<T>(arr1: Array<T>, arr2: Array<T>): Array<T>;
|
package/src/filter.d.ts
CHANGED
|
@@ -11,11 +11,11 @@ import { Maybe } from "./Maybe";
|
|
|
11
11
|
* @returns {[]} The filtered array
|
|
12
12
|
* @example filterByMultiple([{ name: "John", surname: "Doe" }, { name: "Jane", surname: "Doe" }], [p => p.name, p => p.surname], "John") // [{ name: "John", surname: "Doe" }]
|
|
13
13
|
*/
|
|
14
|
-
export declare function filterByMultiple<T>(array: T
|
|
14
|
+
export declare function filterByMultiple<T>(array: Array<T> | null | undefined, props: (p: T) => Array<Maybe<string> | undefined> | null | undefined, match: string): Array<T>;
|
|
15
15
|
/**
|
|
16
16
|
* Filter an array of items based on a list of properties and a search term.
|
|
17
17
|
* The provided properties will be matched based on the term split on space.
|
|
18
18
|
* All terms must have at least one match
|
|
19
19
|
* The terms can match the same property multiple times
|
|
20
20
|
*/
|
|
21
|
-
export declare const fuzzySearch: <T>(elementsToFilter: T
|
|
21
|
+
export declare const fuzzySearch: <T>(elementsToFilter: Array<T>, filterableProps: (element: T) => Array<string>, searchTerm: string) => Array<T>;
|
package/src/groupBy/groupBy.d.ts
CHANGED
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
* groupBy([{ name: "John", surname: "Doe" }, { name: "Jane", surname: "Doe" }], p => p.surname)
|
|
11
11
|
* Returns: Map { "Doe" => [{ name: "John", surname: "Doe" }, { name: "Jane", surname: "Doe" }] }
|
|
12
12
|
*/
|
|
13
|
-
export declare function groupBy<T, K>(list: T
|
|
13
|
+
export declare function groupBy<T, K>(list: Array<T>, getKey: (item: T) => K): Map<K, Array<T>>;
|
package/src/idUtils.d.ts
CHANGED
|
@@ -23,4 +23,4 @@ export declare const toID: (uuid: string) => number;
|
|
|
23
23
|
*
|
|
24
24
|
* @param uuid The list of UUIDs that should be converted to a list of valid machine IDs
|
|
25
25
|
*/
|
|
26
|
-
export declare const toIDs: (ids: string
|
|
26
|
+
export declare const toIDs: (ids: Array<string> | null | undefined) => number[];
|
package/src/objectUtils.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare const objNotEmpty: <T extends object>(obj?: T) => T | undefined;
|
|
|
17
17
|
/**
|
|
18
18
|
* Picks the given keys from an object, typesafe.
|
|
19
19
|
*/
|
|
20
|
-
export declare const pick: <T, K extends keyof T>(obj: T, ...keys: K
|
|
20
|
+
export declare const pick: <T, K extends keyof T>(obj: T, ...keys: Array<K>) => Pick<T, K>;
|
|
21
21
|
/**
|
|
22
22
|
* Returns an object with only the differences between two input objects.
|
|
23
23
|
* Not recursive, only compares first level properties.
|
|
@@ -48,4 +48,4 @@ export declare const removeProperty: <TRecord extends Record<PropertyKey, unknow
|
|
|
48
48
|
* @returns {object} A new object without the specified properties
|
|
49
49
|
* @example removeProperties({ a: 1, b: 2, c: 3 }, ['a', 'b']) // { c: 3 }
|
|
50
50
|
*/
|
|
51
|
-
export declare const removeProperties: <TRecord extends Record<PropertyKey, unknown>, KeyItem extends keyof TRecord>(obj: TRecord, keys:
|
|
51
|
+
export declare const removeProperties: <TRecord extends Record<PropertyKey, unknown>, KeyItem extends keyof TRecord>(obj: TRecord, keys: ReadonlyArray<KeyItem>) => MappedOmit<TRecord, KeyItem>;
|
package/src/sorting/sorting.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export declare const numberCompareUnknownAfterHighest: (a?: Maybe<number>, b?: M
|
|
|
70
70
|
* @example arrayCompare([1, 2], [1, 2], numberCompare) // 0
|
|
71
71
|
* @example arrayCompare([1, 3], [1, 2], numberCompare) // 1
|
|
72
72
|
*/
|
|
73
|
-
export declare const arrayLengthCompare: <T>(a?: Maybe<T
|
|
73
|
+
export declare const arrayLengthCompare: <T>(a?: Maybe<Array<T>>, b?: Maybe<Array<T>>) => number;
|
|
74
74
|
/**
|
|
75
75
|
* Compare two booleans
|
|
76
76
|
*
|
package/src/svgTools.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const rgb2hex: (rgb: string) => string;
|
|
|
7
7
|
/**
|
|
8
8
|
* Returns all svg related colors from a CSSStyleDeclaration
|
|
9
9
|
*/
|
|
10
|
-
export declare const colorsFromStyleDeclaration: (styles: CSSStyleDeclaration) => string
|
|
10
|
+
export declare const colorsFromStyleDeclaration: (styles: CSSStyleDeclaration) => Array<string>;
|
|
11
11
|
/**
|
|
12
12
|
* Loads the dimensions of an SVG string.
|
|
13
13
|
*
|
|
@@ -19,7 +19,7 @@ export declare const loadSVGDimensions: (base64EncodedSVG: string) => Promise<Im
|
|
|
19
19
|
/**
|
|
20
20
|
* Returns an array of all colors used in an svg
|
|
21
21
|
*/
|
|
22
|
-
export declare const getAllColors: (base64EncodedSVG: string) => string
|
|
22
|
+
export declare const getAllColors: (base64EncodedSVG: string) => Array<string>;
|
|
23
23
|
/**
|
|
24
24
|
* Converts a Base64 encoded SVG to a Scaled Base64 PNG.
|
|
25
25
|
*
|
package/src/typeUtils.d.ts
CHANGED
|
@@ -64,10 +64,10 @@ export type MakePropertiesUnion<TOriginal, TUnion> = {
|
|
|
64
64
|
export type DeepPartial<TObject> = TObject extends Record<PropertyKey, unknown> ? {
|
|
65
65
|
[Key in keyof TObject]?: DeepPartial<TObject[Key]>;
|
|
66
66
|
} : TObject;
|
|
67
|
-
export type Entries<TObject> = {
|
|
67
|
+
export type Entries<TObject> = Array<{
|
|
68
68
|
[Key in keyof TObject]: [Key, TObject[Key]];
|
|
69
|
-
}[keyof TObject]
|
|
70
|
-
type KeyValueTupleToObject<TEntries extends readonly
|
|
69
|
+
}[keyof TObject]>;
|
|
70
|
+
type KeyValueTupleToObject<TEntries extends ReadonlyArray<readonly [PropertyKey, unknown]>> = {
|
|
71
71
|
[Key in TEntries[number] as Key[0]]: Key[1];
|
|
72
72
|
};
|
|
73
73
|
/**
|
|
@@ -90,7 +90,7 @@ export declare const objectEntries: <TObject extends Record<PropertyKey, unknown
|
|
|
90
90
|
* @param {TEntries} entries - The array of key-value pairs to convert.
|
|
91
91
|
* @template TEntries - The type of the entries array.
|
|
92
92
|
*/
|
|
93
|
-
export declare const objectFromEntries: <const TEntries extends readonly
|
|
93
|
+
export declare const objectFromEntries: <const TEntries extends ReadonlyArray<readonly [PropertyKey, unknown]>>(entries: TEntries) => KeyValueTupleToObject<TEntries>;
|
|
94
94
|
/**
|
|
95
95
|
* Returns an array of the **correctly typed** keys of a given object.
|
|
96
96
|
* This is a type-faithful alternative to Object.keys().
|
|
@@ -104,7 +104,7 @@ export declare const objectFromEntries: <const TEntries extends readonly (readon
|
|
|
104
104
|
* @param {TObject} object - The object to get the keys from.
|
|
105
105
|
* @returns {(keyof TObject)[]} An array of the keys of the object.
|
|
106
106
|
*/
|
|
107
|
-
export declare const objectKeys: <TObject extends Record<PropertyKey, unknown>>(object: TObject) =>
|
|
107
|
+
export declare const objectKeys: <TObject extends Record<PropertyKey, unknown>>(object: TObject) => Array<keyof TObject>;
|
|
108
108
|
/**
|
|
109
109
|
* Returns an array of the **correctly typed** values of a given object.
|
|
110
110
|
* This is a type-faithful alternative to Object.values().
|
|
@@ -116,5 +116,5 @@ export declare const objectKeys: <TObject extends Record<PropertyKey, unknown>>(
|
|
|
116
116
|
* @param {TObject} object - The object to get the values from.
|
|
117
117
|
* @returns {TObject[keyof TObject][]} An array of the values of the object.
|
|
118
118
|
*/
|
|
119
|
-
export declare const objectValues: <TObject extends Record<PropertyKey, unknown>>(object: TObject) => TObject[keyof TObject]
|
|
119
|
+
export declare const objectValues: <TObject extends Record<PropertyKey, unknown>>(object: TObject) => Array<TObject[keyof TObject]>;
|
|
120
120
|
export {};
|