@dereekb/util 12.0.4 → 12.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/fetch/package.json +1 -1
- package/index.cjs.js +14 -9
- package/index.esm.js +14 -9
- package/package.json +1 -1
- package/src/lib/sort.d.ts +6 -6
- package/src/lib/value/maybe.type.d.ts +4 -0
- package/test/CHANGELOG.md +8 -0
- package/test/package.json +1 -1
package/fetch/package.json
CHANGED
package/index.cjs.js
CHANGED
|
@@ -4841,20 +4841,25 @@ function compareWithMappedValuesFunction(mapValue, comparesFunction) {
|
|
|
4841
4841
|
/**
|
|
4842
4842
|
* Sorts the input values using the input.
|
|
4843
4843
|
*
|
|
4844
|
-
* @param
|
|
4844
|
+
* @param input
|
|
4845
4845
|
* @returns
|
|
4846
4846
|
*/
|
|
4847
|
-
function sortValues({
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4847
|
+
function sortValues(input) {
|
|
4848
|
+
const {
|
|
4849
|
+
values,
|
|
4850
|
+
alwaysReturnCopy,
|
|
4851
|
+
sortOnCopy,
|
|
4852
|
+
sortWith
|
|
4853
|
+
} = input;
|
|
4853
4854
|
const doSort = sortWith != null;
|
|
4855
|
+
let result = values;
|
|
4854
4856
|
if (alwaysReturnCopy || sortOnCopy && doSort) {
|
|
4855
|
-
|
|
4857
|
+
result = [...values];
|
|
4856
4858
|
}
|
|
4857
|
-
|
|
4859
|
+
if (doSort) {
|
|
4860
|
+
result = result.sort(sortWith);
|
|
4861
|
+
}
|
|
4862
|
+
return result;
|
|
4858
4863
|
}
|
|
4859
4864
|
/**
|
|
4860
4865
|
* Creates a SortValuesFunction using the input.
|
package/index.esm.js
CHANGED
|
@@ -4839,20 +4839,25 @@ function compareWithMappedValuesFunction(mapValue, comparesFunction) {
|
|
|
4839
4839
|
/**
|
|
4840
4840
|
* Sorts the input values using the input.
|
|
4841
4841
|
*
|
|
4842
|
-
* @param
|
|
4842
|
+
* @param input
|
|
4843
4843
|
* @returns
|
|
4844
4844
|
*/
|
|
4845
|
-
function sortValues({
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4845
|
+
function sortValues(input) {
|
|
4846
|
+
const {
|
|
4847
|
+
values,
|
|
4848
|
+
alwaysReturnCopy,
|
|
4849
|
+
sortOnCopy,
|
|
4850
|
+
sortWith
|
|
4851
|
+
} = input;
|
|
4851
4852
|
const doSort = sortWith != null;
|
|
4853
|
+
let result = values;
|
|
4852
4854
|
if (alwaysReturnCopy || sortOnCopy && doSort) {
|
|
4853
|
-
|
|
4855
|
+
result = [...values];
|
|
4854
4856
|
}
|
|
4855
|
-
|
|
4857
|
+
if (doSort) {
|
|
4858
|
+
result = result.sort(sortWith);
|
|
4859
|
+
}
|
|
4860
|
+
return result;
|
|
4856
4861
|
}
|
|
4857
4862
|
/**
|
|
4858
4863
|
* Creates a SortValuesFunction using the input.
|
package/package.json
CHANGED
package/src/lib/sort.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export type SortValuesFunction<T> = (values: T[], sortOnCopy?: boolean) => T[];
|
|
|
68
68
|
/**
|
|
69
69
|
* Input for sortValues().
|
|
70
70
|
*/
|
|
71
|
-
export
|
|
71
|
+
export type SortValuesInput<T> = MaybeMap<Partial<SortCompareFunctionRef<T>>> & {
|
|
72
72
|
/**
|
|
73
73
|
* Values to sort.
|
|
74
74
|
*/
|
|
@@ -76,19 +76,19 @@ export interface SortValuesInput<T> extends MaybeMap<SortCompareFunctionRef<T>>
|
|
|
76
76
|
/**
|
|
77
77
|
* Whether or not to sort on a copy of the input values.
|
|
78
78
|
*/
|
|
79
|
-
readonly sortOnCopy?: boolean
|
|
79
|
+
readonly sortOnCopy?: Maybe<boolean>;
|
|
80
80
|
/**
|
|
81
81
|
* Whether or not to always return a copy of the input values, even if no sorting occurs.
|
|
82
82
|
*/
|
|
83
|
-
readonly alwaysReturnCopy?: boolean
|
|
84
|
-
}
|
|
83
|
+
readonly alwaysReturnCopy?: Maybe<boolean>;
|
|
84
|
+
};
|
|
85
85
|
/**
|
|
86
86
|
* Sorts the input values using the input.
|
|
87
87
|
*
|
|
88
|
-
* @param
|
|
88
|
+
* @param input
|
|
89
89
|
* @returns
|
|
90
90
|
*/
|
|
91
|
-
export declare function sortValues<T>(
|
|
91
|
+
export declare function sortValues<T>(input: SortValuesInput<T>): T[];
|
|
92
92
|
/**
|
|
93
93
|
* Creates a SortValuesFunction using the input.
|
|
94
94
|
*
|
|
@@ -11,6 +11,10 @@ export type MaybeSo<T = unknown> = T extends MaybeNot ? never : T;
|
|
|
11
11
|
* A value that might exist, or be null/undefined instead.
|
|
12
12
|
*/
|
|
13
13
|
export type Maybe<T> = T | MaybeNot;
|
|
14
|
+
/**
|
|
15
|
+
* A value that is not null/undefined.
|
|
16
|
+
*/
|
|
17
|
+
export type MaybeSoStrict<T> = T extends Maybe<infer A> ? (A extends Maybe<infer B> ? B extends Maybe<infer C> ? C extends Maybe<infer D> ? D extends Maybe<infer E> ? E : D : C : B : A) : T;
|
|
14
18
|
/**
|
|
15
19
|
* Turns all key values in an object into a Maybe value.
|
|
16
20
|
*/
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [12.0.6](https://github.com/dereekb/dbx-components/compare/v12.0.5-dev...v12.0.6) (2025-05-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [12.0.5](https://github.com/dereekb/dbx-components/compare/v12.0.4-dev...v12.0.5) (2025-05-02)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [12.0.4](https://github.com/dereekb/dbx-components/compare/v12.0.3-dev...v12.0.4) (2025-04-29)
|
|
6
14
|
|
|
7
15
|
|