@dereekb/util 12.0.4 → 12.0.5

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util/fetch",
3
- "version": "12.0.4",
3
+ "version": "12.0.5",
4
4
  ".": {
5
5
  "types": "./src/index.d.ts",
6
6
  "node": {
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 param0
4844
+ * @param input
4845
4845
  * @returns
4846
4846
  */
4847
- function sortValues({
4848
- values,
4849
- alwaysReturnCopy,
4850
- sortOnCopy,
4851
- sortWith
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
- values = [...values];
4857
+ result = [...values];
4856
4858
  }
4857
- return doSort ? values.sort(sortWith) : values;
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 param0
4842
+ * @param input
4843
4843
  * @returns
4844
4844
  */
4845
- function sortValues({
4846
- values,
4847
- alwaysReturnCopy,
4848
- sortOnCopy,
4849
- sortWith
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
- values = [...values];
4855
+ result = [...values];
4854
4856
  }
4855
- return doSort ? values.sort(sortWith) : values;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util",
3
- "version": "12.0.4",
3
+ "version": "12.0.5",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./src/index.d.ts",
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 interface SortValuesInput<T> extends MaybeMap<SortCompareFunctionRef<T>> {
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 param0
88
+ * @param input
89
89
  * @returns
90
90
  */
91
- export declare function sortValues<T>({ values, alwaysReturnCopy, sortOnCopy, sortWith }: SortValuesInput<T>): 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,10 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [12.0.5](https://github.com/dereekb/dbx-components/compare/v12.0.4-dev...v12.0.5) (2025-05-02)
6
+
7
+
8
+
5
9
  ## [12.0.4](https://github.com/dereekb/dbx-components/compare/v12.0.3-dev...v12.0.4) (2025-04-29)
6
10
 
7
11
 
package/test/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util/test",
3
- "version": "12.0.4",
3
+ "version": "12.0.5",
4
4
  "type": "commonjs",
5
5
  "peerDependencies": {
6
6
  "@dereekb/util": "*"