@dereekb/util 9.25.5 → 9.25.7
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/CHANGELOG.md +8 -0
- package/fetch/CHANGELOG.md +8 -0
- package/fetch/package.json +2 -2
- package/package.json +1 -1
- package/src/lib/sort.d.ts +62 -0
- package/src/lib/sort.js +43 -1
- package/src/lib/sort.js.map +1 -1
- package/test/CHANGELOG.md +8 -0
- package/test/package.json +2 -2
package/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
|
+
## [9.25.7](https://github.com/dereekb/dbx-components/compare/v9.25.6-dev...v9.25.7) (2023-10-26)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [9.25.6](https://github.com/dereekb/dbx-components/compare/v9.25.5-dev...v9.25.6) (2023-10-17)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [9.25.5](https://github.com/dereekb/dbx-components/compare/v9.25.4-dev...v9.25.5) (2023-10-16)
|
|
6
14
|
|
|
7
15
|
|
package/fetch/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
|
+
## [9.25.7](https://github.com/dereekb/dbx-components/compare/v9.25.6-dev...v9.25.7) (2023-10-26)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [9.25.6](https://github.com/dereekb/dbx-components/compare/v9.25.5-dev...v9.25.6) (2023-10-17)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [9.25.5](https://github.com/dereekb/dbx-components/compare/v9.25.4-dev...v9.25.5) (2023-10-16)
|
|
6
14
|
|
|
7
15
|
|
package/fetch/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/util/fetch",
|
|
3
|
-
"version": "9.25.
|
|
3
|
+
"version": "9.25.7",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"types": "./src/index.d.ts",
|
|
6
6
|
"dependencies": {},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@dereekb/util": "9.25.
|
|
8
|
+
"@dereekb/util": "9.25.7",
|
|
9
9
|
"lodash.isequal": "^4.5.0",
|
|
10
10
|
"make-error": "^1.3.0",
|
|
11
11
|
"class-validator": "^0.13.2",
|
package/package.json
CHANGED
package/src/lib/sort.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MapSameFunction } from './value/map';
|
|
2
|
+
import { Maybe, MaybeMap } from './value/maybe.type';
|
|
1
3
|
export declare type SortingOrder = 'asc' | 'desc';
|
|
2
4
|
export declare const SORT_VALUE_LESS_THAN: SortComparisonNumber;
|
|
3
5
|
export declare const SORT_VALUE_GREATER_THAN: SortComparisonNumber;
|
|
@@ -19,6 +21,15 @@ export declare type SortComparisonNumber = number;
|
|
|
19
21
|
* A comparison function that returns a SortComparisonNumber.
|
|
20
22
|
*/
|
|
21
23
|
export declare type SortCompareFunction<T> = (a: T, b: T) => SortComparisonNumber;
|
|
24
|
+
/**
|
|
25
|
+
* An object that has a reference to a SortCompareFunction<T> function.
|
|
26
|
+
*/
|
|
27
|
+
export interface SortCompareFunctionRef<T> {
|
|
28
|
+
/**
|
|
29
|
+
* Sort comparison function to sort with.
|
|
30
|
+
*/
|
|
31
|
+
readonly sortWith: SortCompareFunction<T>;
|
|
32
|
+
}
|
|
22
33
|
/**
|
|
23
34
|
* Comparison function that sorts in ascending order.
|
|
24
35
|
*/
|
|
@@ -38,6 +49,57 @@ export declare function reverseCompareFn<T>(compareFn: SortDescendingCompareFunc
|
|
|
38
49
|
* The input comparison function must be in ascending order.
|
|
39
50
|
*/
|
|
40
51
|
export declare function compareFnOrder<T>(ascendingCompareFn: AscendingSortCompareFunction<T>, order?: SortingOrder): SortCompareFunction<T>;
|
|
52
|
+
/**
|
|
53
|
+
* Simple SortValuesFunction that only sorts the input and has no configuration.
|
|
54
|
+
*/
|
|
55
|
+
export declare type SimpleSortValuesFunction<T> = MapSameFunction<T[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Function that sorts the input values array. Can be configured to return a copy.
|
|
58
|
+
*/
|
|
59
|
+
export declare type SortValuesFunction<T> = (values: T[], sortOnCopy?: boolean) => T[];
|
|
60
|
+
/**
|
|
61
|
+
* Input for sortValues().
|
|
62
|
+
*/
|
|
63
|
+
export interface SortValuesInput<T> extends MaybeMap<SortCompareFunctionRef<T>> {
|
|
64
|
+
/**
|
|
65
|
+
* Values to sort.
|
|
66
|
+
*/
|
|
67
|
+
readonly values: T[];
|
|
68
|
+
/**
|
|
69
|
+
* Whether or not to sort on a copy of the input values.
|
|
70
|
+
*/
|
|
71
|
+
readonly sortOnCopy?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Whether or not to always return a copy of the input values, even if no sorting occurs.
|
|
74
|
+
*/
|
|
75
|
+
readonly alwaysReturnCopy?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Sorts the input values using the input.
|
|
79
|
+
*
|
|
80
|
+
* @param param0
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
export declare function sortValues<T>({ values, alwaysReturnCopy, sortOnCopy, sortWith }: SortValuesInput<T>): T[];
|
|
84
|
+
/**
|
|
85
|
+
* Creates a SortValuesFunction using the input.
|
|
86
|
+
*
|
|
87
|
+
* @param sortRef
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
export declare function sortValuesFunctionWithSortRef<T>(sortRef: Maybe<Partial<SortCompareFunctionRef<T>>>, sortOnCopyDefault?: boolean): SortValuesFunction<T>;
|
|
91
|
+
/**
|
|
92
|
+
* Creates a SortValuesFunction using the input. If the input is not defined, or it's sort function is not defined, then returns mapIdentityFunction().
|
|
93
|
+
*/
|
|
94
|
+
export declare function sortValuesFunctionOrMapIdentityWithSortRef<T>(sortRef: Maybe<Partial<SortCompareFunctionRef<T>>>, sortOnCopyDefault?: boolean): SortValuesFunction<T>;
|
|
95
|
+
/**
|
|
96
|
+
* Equivalent to sortValuesFunctionOrMapIdentityWithSortRef(), but returns a SimpleSortValuesFunction instead.
|
|
97
|
+
*
|
|
98
|
+
* @param sortRef
|
|
99
|
+
* @param sortOnCopyDefault
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
export declare const simpleSortValuesFunctionWithSortRef: <T>(sortRef: Maybe<Partial<SortCompareFunctionRef<T>>>, sortOnCopyDefault?: boolean) => SimpleSortValuesFunction<T>;
|
|
41
103
|
export interface MinAndMax<T> {
|
|
42
104
|
min: T;
|
|
43
105
|
max: T;
|
package/src/lib/sort.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.minAndMaxFunction = exports.compareFnOrder = exports.reverseCompareFn = exports.SORT_VALUE_EQUAL = exports.SORT_VALUE_GREATER_THAN = exports.SORT_VALUE_LESS_THAN = void 0;
|
|
3
|
+
exports.minAndMaxFunction = exports.simpleSortValuesFunctionWithSortRef = exports.sortValuesFunctionOrMapIdentityWithSortRef = exports.sortValuesFunctionWithSortRef = exports.sortValues = exports.compareFnOrder = exports.reverseCompareFn = exports.SORT_VALUE_EQUAL = exports.SORT_VALUE_GREATER_THAN = exports.SORT_VALUE_LESS_THAN = void 0;
|
|
4
4
|
const iterable_1 = require("./iterable/iterable");
|
|
5
|
+
const map_1 = require("./value/map");
|
|
5
6
|
exports.SORT_VALUE_LESS_THAN = -1;
|
|
6
7
|
exports.SORT_VALUE_GREATER_THAN = 1;
|
|
7
8
|
exports.SORT_VALUE_EQUAL = 0;
|
|
@@ -18,6 +19,47 @@ function compareFnOrder(ascendingCompareFn, order = 'asc') {
|
|
|
18
19
|
return order === 'asc' ? ascendingCompareFn : reverseCompareFn(ascendingCompareFn);
|
|
19
20
|
}
|
|
20
21
|
exports.compareFnOrder = compareFnOrder;
|
|
22
|
+
/**
|
|
23
|
+
* Sorts the input values using the input.
|
|
24
|
+
*
|
|
25
|
+
* @param param0
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
function sortValues({ values, alwaysReturnCopy, sortOnCopy, sortWith }) {
|
|
29
|
+
const doSort = sortWith != null;
|
|
30
|
+
if (alwaysReturnCopy || (sortOnCopy && doSort)) {
|
|
31
|
+
values = [...values];
|
|
32
|
+
}
|
|
33
|
+
return doSort ? values.sort(sortWith) : values;
|
|
34
|
+
}
|
|
35
|
+
exports.sortValues = sortValues;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a SortValuesFunction using the input.
|
|
38
|
+
*
|
|
39
|
+
* @param sortRef
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
function sortValuesFunctionWithSortRef(sortRef, sortOnCopyDefault = true) {
|
|
43
|
+
const sortWith = sortRef === null || sortRef === void 0 ? void 0 : sortRef.sortWith;
|
|
44
|
+
return (values, sortOnCopy = sortOnCopyDefault) => sortValues({ values, sortOnCopy, sortWith });
|
|
45
|
+
}
|
|
46
|
+
exports.sortValuesFunctionWithSortRef = sortValuesFunctionWithSortRef;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a SortValuesFunction using the input. If the input is not defined, or it's sort function is not defined, then returns mapIdentityFunction().
|
|
49
|
+
*/
|
|
50
|
+
function sortValuesFunctionOrMapIdentityWithSortRef(sortRef, sortOnCopyDefault) {
|
|
51
|
+
const sortWith = sortRef === null || sortRef === void 0 ? void 0 : sortRef.sortWith;
|
|
52
|
+
return sortWith ? sortValuesFunctionWithSortRef(sortRef, sortOnCopyDefault) : (0, map_1.mapIdentityFunction)();
|
|
53
|
+
}
|
|
54
|
+
exports.sortValuesFunctionOrMapIdentityWithSortRef = sortValuesFunctionOrMapIdentityWithSortRef;
|
|
55
|
+
/**
|
|
56
|
+
* Equivalent to sortValuesFunctionOrMapIdentityWithSortRef(), but returns a SimpleSortValuesFunction instead.
|
|
57
|
+
*
|
|
58
|
+
* @param sortRef
|
|
59
|
+
* @param sortOnCopyDefault
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
exports.simpleSortValuesFunctionWithSortRef = sortValuesFunctionOrMapIdentityWithSortRef;
|
|
21
63
|
/**
|
|
22
64
|
* Creates a MinAndMaxFunction using the input compare.
|
|
23
65
|
*
|
package/src/lib/sort.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.js","sourceRoot":"","sources":["../../../../../packages/util/src/lib/sort.ts"],"names":[],"mappings":";;;AAAA,kDAAgF;AAKnE,QAAA,oBAAoB,GAAyB,CAAC,CAAC,CAAC;AAChD,QAAA,uBAAuB,GAAyB,CAAC,CAAC;AAClD,QAAA,gBAAgB,GAAyB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"sort.js","sourceRoot":"","sources":["../../../../../packages/util/src/lib/sort.ts"],"names":[],"mappings":";;;AAAA,kDAAgF;AAChF,qCAAgF;AAKnE,QAAA,oBAAoB,GAAyB,CAAC,CAAC,CAAC;AAChD,QAAA,uBAAuB,GAAyB,CAAC,CAAC;AAClD,QAAA,gBAAgB,GAAyB,CAAC,CAAC;AA8CxD,SAAgB,gBAAgB,CAAI,SAAiC;IACnE,OAAO,CAAC,CAAI,EAAE,CAAI,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9C,CAAC;AAFD,4CAEC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAI,kBAAmD,EAAE,QAAsB,KAAK;IAChH,OAAO,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;AACrF,CAAC;A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QAChE,IAAI,GAAG,GAAa,GAAG,CAAC;QAExB,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,EAAE;YAC9B,IAAA,4BAAiB,EAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;gBAC9B,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,EAAE,GAAQ,CAAC,CAAC;gBAC1C,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,EAAE,GAAQ,CAAC,CAAC;gBAE1C,IAAI,UAAU,GAAG,CAAC,EAAE;oBAClB,GAAG,GAAG,CAAC,CAAC;iBACT;gBAED,IAAI,UAAU,GAAG,CAAC,EAAE;oBAClB,GAAG,GAAG,CAAC,CAAC;iBACT;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;SACrB;aAAM;YACL,OAAO,IAAI,CAAC;SACb;IACH,CAAC,CAAC;AACJ,CAAC;AAxBD,8CAwBC"}
|
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
|
+
## [9.25.7](https://github.com/dereekb/dbx-components/compare/v9.25.6-dev...v9.25.7) (2023-10-26)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [9.25.6](https://github.com/dereekb/dbx-components/compare/v9.25.5-dev...v9.25.6) (2023-10-17)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [9.25.5](https://github.com/dereekb/dbx-components/compare/v9.25.4-dev...v9.25.5) (2023-10-16)
|
|
6
14
|
|
|
7
15
|
|
package/test/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/util/test",
|
|
3
|
-
"version": "9.25.
|
|
3
|
+
"version": "9.25.7",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@dereekb/util": "9.25.
|
|
9
|
+
"@dereekb/util": "9.25.7",
|
|
10
10
|
"lodash.isequal": "^4.5.0",
|
|
11
11
|
"make-error": "^1.3.0",
|
|
12
12
|
"class-validator": "^0.13.2",
|