@oscarpalmer/atoms 0.167.0 → 0.169.0
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/dist/array/index.d.mts +1 -2
- package/dist/array/index.mjs +1 -2
- package/dist/array/sort.d.mts +29 -5
- package/dist/array/sort.mjs +27 -14
- package/dist/index.d.mts +122 -98
- package/dist/index.mjs +228 -212
- package/dist/internal/is.d.mts +8 -2
- package/dist/internal/is.mjs +10 -1
- package/dist/internal/value/equal.mjs +9 -17
- package/dist/is.d.mts +1 -8
- package/dist/is.mjs +1 -10
- package/dist/sized/map.mjs +13 -7
- package/dist/sized/set.mjs +4 -4
- package/dist/value/clone.mjs +17 -14
- package/dist/value/diff.mjs +10 -9
- package/package.json +6 -2
- package/src/array/index.ts +0 -1
- package/src/array/sort.ts +100 -63
- package/src/index.ts +1 -0
- package/src/internal/is.ts +19 -1
- package/src/internal/value/equal.ts +21 -24
- package/src/is.ts +1 -11
- package/src/sized/map.ts +17 -11
- package/src/sized/set.ts +6 -5
- package/src/value/clone.ts +39 -23
- package/src/value/diff.ts +15 -16
package/dist/array/index.d.mts
CHANGED
|
@@ -15,11 +15,10 @@ import { ArrayPosition, endsWithArray, getArrayPosition, includesArray, indexOfA
|
|
|
15
15
|
import { push } from "./push.mjs";
|
|
16
16
|
import { select } from "./select.mjs";
|
|
17
17
|
import { drop, slice, take } from "./slice.mjs";
|
|
18
|
-
import { ArrayComparisonSorter, ArrayKeySorter, ArrayValueSorter, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, SortDirection, sort } from "./sort.mjs";
|
|
19
18
|
import { splice } from "./splice.mjs";
|
|
20
19
|
import { toSet } from "./to-set.mjs";
|
|
21
20
|
import { toggle } from "./toggle.mjs";
|
|
22
21
|
import { union } from "./union.mjs";
|
|
23
22
|
import { unique } from "./unique.mjs";
|
|
24
23
|
import { update } from "./update.mjs";
|
|
25
|
-
export {
|
|
24
|
+
export { ArrayPosition, chunk, compact, difference, drop, endsWithArray, exists, find, flatten, getArray, getArrayPosition, includesArray, indexOf, indexOfArray, insert, intersection, partition, push, range, select, shuffle, slice, splice, startsWithArray, take, times, toSet, toggle, union, unique, update };
|
package/dist/array/index.mjs
CHANGED
|
@@ -15,11 +15,10 @@ import { endsWithArray, getArrayPosition, includesArray, indexOfArray, startsWit
|
|
|
15
15
|
import { push } from "./push.mjs";
|
|
16
16
|
import { select } from "./select.mjs";
|
|
17
17
|
import { drop, slice, take } from "./slice.mjs";
|
|
18
|
-
import { SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, sort } from "./sort.mjs";
|
|
19
18
|
import { splice } from "./splice.mjs";
|
|
20
19
|
import { toSet } from "./to-set.mjs";
|
|
21
20
|
import { toggle } from "./toggle.mjs";
|
|
22
21
|
import { union } from "./union.mjs";
|
|
23
22
|
import { unique } from "./unique.mjs";
|
|
24
23
|
import { update } from "./update.mjs";
|
|
25
|
-
export {
|
|
24
|
+
export { chunk, compact, difference, drop, endsWithArray, exists, find, flatten, getArray, getArrayPosition, includesArray, indexOf, indexOfArray, insert, intersection, partition, push, range, select, shuffle, slice, splice, startsWithArray, take, times, toSet, toggle, union, unique, update };
|
package/dist/array/sort.d.mts
CHANGED
|
@@ -35,6 +35,10 @@ type ArrayKeySorter<Item extends PlainObject, ItemKey extends keyof Item> = {
|
|
|
35
35
|
* Sorters based on keys in an object
|
|
36
36
|
*/
|
|
37
37
|
type ArrayKeySorters<Item extends PlainObject> = { [ItemKey in keyof Item]: ArrayKeySorter<Item, ItemKey> }[keyof Item];
|
|
38
|
+
/**
|
|
39
|
+
* Sorter to use for sorting
|
|
40
|
+
*/
|
|
41
|
+
type ArraySorter<Item> = Item extends PlainObject ? keyof Item | ArrayComparisonSorter<Item> | ArrayKeySorters<Item> | ArrayValueSorter<Item> | ComparisonSorter<Item> : ArrayComparisonSorter<Item> | ArrayValueSorter<Item> | ComparisonSorter<Item>;
|
|
38
42
|
/**
|
|
39
43
|
* Sorting information for arrays _(using a value callback and built-in comparison)_
|
|
40
44
|
*/
|
|
@@ -61,10 +65,27 @@ type ComparisonSorter<Item> = (first: Item, second: Item) => number;
|
|
|
61
65
|
* Direction to sort by
|
|
62
66
|
*/
|
|
63
67
|
type SortDirection = 'ascending' | 'descending';
|
|
68
|
+
type Sorter<Item> = (array: Item[]) => Item[];
|
|
64
69
|
/**
|
|
65
|
-
*
|
|
70
|
+
* Initialize a sort handler with sorters _(and an optional default direction)_
|
|
71
|
+
* @param sorters Sorters to use for sorting
|
|
72
|
+
* @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
73
|
+
* @returns Sort handler
|
|
74
|
+
*/
|
|
75
|
+
declare function initializeSort<Item>(sorters: Array<ArraySorter<Item>>, descending?: boolean): Sorter<Item>;
|
|
76
|
+
/**
|
|
77
|
+
* Initialize a sort handler with a sorter _(and an optional default direction)_
|
|
78
|
+
* @param sorter Sorter to use for sorting
|
|
79
|
+
* @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
80
|
+
* @returns Sort handler
|
|
81
|
+
*/
|
|
82
|
+
declare function initializeSort<Item>(sorter: ArraySorter<Item>, descending?: boolean): Sorter<Item>;
|
|
83
|
+
/**
|
|
84
|
+
* Initialize a sort handler _(with an optional default direction)_
|
|
85
|
+
* @param descending Sort in descending order? _(defaults to `false`)_
|
|
86
|
+
* @returns Sort handler
|
|
66
87
|
*/
|
|
67
|
-
|
|
88
|
+
declare function initializeSort<Item>(descending?: boolean): Sorter<Item>;
|
|
68
89
|
/**
|
|
69
90
|
* Sort an array of items, using multiple sorters to sort by specific values
|
|
70
91
|
* @param array Array to sort
|
|
@@ -72,7 +93,7 @@ type Sorter<Item> = Item extends PlainObject ? keyof Item | ArrayComparisonSorte
|
|
|
72
93
|
* @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
73
94
|
* @returns Sorted array
|
|
74
95
|
*/
|
|
75
|
-
declare function sort<Item>(array: Item[], sorters: Array<
|
|
96
|
+
declare function sort<Item>(array: Item[], sorters: Array<ArraySorter<Item>>, descending?: boolean): Item[];
|
|
76
97
|
/**
|
|
77
98
|
* Sort an array of items, using multiple sorters to sort by specific values
|
|
78
99
|
* @param array Array to sort
|
|
@@ -80,7 +101,7 @@ declare function sort<Item>(array: Item[], sorters: Array<Sorter<Item>>, descend
|
|
|
80
101
|
* @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
81
102
|
* @returns Sorted array
|
|
82
103
|
*/
|
|
83
|
-
declare function sort<Item>(array: Item[], sorter:
|
|
104
|
+
declare function sort<Item>(array: Item[], sorter: ArraySorter<Item>, descending?: boolean): Item[];
|
|
84
105
|
/**
|
|
85
106
|
* Sort an array of items
|
|
86
107
|
* @param array Array to sort
|
|
@@ -88,7 +109,10 @@ declare function sort<Item>(array: Item[], sorter: Sorter<Item>, descending?: bo
|
|
|
88
109
|
* @returns Sorted array
|
|
89
110
|
*/
|
|
90
111
|
declare function sort<Item>(array: Item[], descending?: boolean): Item[];
|
|
112
|
+
declare namespace sort {
|
|
113
|
+
var initialize: typeof initializeSort;
|
|
114
|
+
}
|
|
91
115
|
declare const SORT_DIRECTION_ASCENDING: SortDirection;
|
|
92
116
|
declare const SORT_DIRECTION_DESCENDING: SortDirection;
|
|
93
117
|
//#endregion
|
|
94
|
-
export { ArrayComparisonSorter, ArrayKeySorter, ArrayValueSorter, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, SortDirection, sort };
|
|
118
|
+
export { ArrayComparisonSorter, ArrayKeySorter, ArrayValueSorter, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, SortDirection, Sorter, sort };
|
package/dist/array/sort.mjs
CHANGED
|
@@ -9,6 +9,9 @@ function getComparisonSorter(callback, modifier) {
|
|
|
9
9
|
identifier: String(callback)
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
+
function getModifier(first, second) {
|
|
13
|
+
return modifiers[first === true || second === true ? SORT_DIRECTION_DESCENDING : SORT_DIRECTION_ASCENDING];
|
|
14
|
+
}
|
|
12
15
|
function getObjectSorter(obj, modifier) {
|
|
13
16
|
let sorter;
|
|
14
17
|
if (typeof obj.comparison === "function") sorter = getComparisonSorter(obj.comparison, modifier);
|
|
@@ -27,6 +30,17 @@ function getSorter(value, modifier) {
|
|
|
27
30
|
default: break;
|
|
28
31
|
}
|
|
29
32
|
}
|
|
33
|
+
function getSorters(value, modifier) {
|
|
34
|
+
const array = Array.isArray(value) ? value : [value];
|
|
35
|
+
const { length } = array;
|
|
36
|
+
const sorters = [];
|
|
37
|
+
for (let index = 0; index < length; index += 1) {
|
|
38
|
+
const item = array[index];
|
|
39
|
+
const sorter = getSorter(item, modifier);
|
|
40
|
+
if (sorter != null) sorters.push(sorter);
|
|
41
|
+
}
|
|
42
|
+
return sorters.filter((value, index, array) => array.findIndex((next) => next.identifier === value.identifier) === index);
|
|
43
|
+
}
|
|
30
44
|
function getValueSorter(value, modifier) {
|
|
31
45
|
return {
|
|
32
46
|
modifier,
|
|
@@ -35,32 +49,31 @@ function getValueSorter(value, modifier) {
|
|
|
35
49
|
value: typeof value === "function" ? value : (item) => item[value]
|
|
36
50
|
};
|
|
37
51
|
}
|
|
52
|
+
function initializeSort(first, second) {
|
|
53
|
+
const modifier = getModifier(first, second);
|
|
54
|
+
const sorters = getSorters(first, modifier);
|
|
55
|
+
return (array) => work(array, sorters, modifier);
|
|
56
|
+
}
|
|
38
57
|
function sort(array, first, second) {
|
|
58
|
+
const modifier = getModifier(first, second);
|
|
59
|
+
return work(array, getSorters(first, modifier), modifier);
|
|
60
|
+
}
|
|
61
|
+
function work(array, sorters, modifier) {
|
|
39
62
|
if (!Array.isArray(array)) return [];
|
|
40
63
|
if (array.length < 2) return array;
|
|
41
|
-
const modifier = modifiers[first === true || second === true ? SORT_DIRECTION_DESCENDING : SORT_DIRECTION_ASCENDING];
|
|
42
|
-
const sorters = (Array.isArray(first) ? first : [first]).map((item) => getSorter(item, modifier)).filter((sorter) => sorter != null).filter((current, index, filtered) => filtered.findIndex((next) => next.identifier === current.identifier) === index);
|
|
43
64
|
const { length } = sorters;
|
|
44
65
|
if (length === 0) return array.sort((first, second) => compare(first, second) * modifier);
|
|
45
|
-
|
|
46
|
-
const sorter = sorters[0];
|
|
47
|
-
return array.sort((firstItem, secondItem) => {
|
|
48
|
-
const firstValue = sorter.get ? sorter.value(firstItem) : firstItem;
|
|
49
|
-
const secondValue = sorter.get ? sorter.value(secondItem) : secondItem;
|
|
50
|
-
return (sorter.compare?.complex?.(firstItem, firstValue, secondItem, secondValue) ?? sorter.compare?.simple?.(firstItem, secondItem) ?? compare(firstValue, secondValue)) * sorter.modifier;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return array.sort((firstItem, secondItem) => {
|
|
66
|
+
return array.sort((first, second) => {
|
|
54
67
|
for (let index = 0; index < length; index += 1) {
|
|
55
68
|
const sorter = sorters[index];
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const comparison = (sorter.compare?.complex?.(firstItem, firstValue, secondItem, secondValue) ?? sorter.compare?.simple?.(firstItem, secondItem) ?? compare(firstValue, secondValue)) * sorter.modifier;
|
|
69
|
+
const values = [sorter.get ? sorter.value(first) : first, sorter.get ? sorter.value(second) : second];
|
|
70
|
+
const comparison = (sorter.compare?.complex?.(first, values[0], second, values[1]) ?? sorter.compare?.simple?.(values[0], values[1]) ?? compare(values[0], values[1])) * sorter.modifier;
|
|
59
71
|
if (comparison !== 0) return comparison;
|
|
60
72
|
}
|
|
61
73
|
return 0;
|
|
62
74
|
});
|
|
63
75
|
}
|
|
76
|
+
sort.initialize = initializeSort;
|
|
64
77
|
const SORT_DIRECTION_ASCENDING = "ascending";
|
|
65
78
|
const SORT_DIRECTION_DESCENDING = "descending";
|
|
66
79
|
const modifiers = {
|
package/dist/index.d.mts
CHANGED
|
@@ -853,97 +853,6 @@ declare function take<Item extends PlainObject>(array: Item[], callback: (item:
|
|
|
853
853
|
*/
|
|
854
854
|
declare function take(array: unknown[], count: number): unknown[];
|
|
855
855
|
//#endregion
|
|
856
|
-
//#region src/array/sort.d.ts
|
|
857
|
-
/**
|
|
858
|
-
* Sorting information for arrays _(using a comparison callback)_
|
|
859
|
-
*/
|
|
860
|
-
type ArrayComparisonSorter<Item> = {
|
|
861
|
-
/**
|
|
862
|
-
* Callback to use when comparing items and values
|
|
863
|
-
*/
|
|
864
|
-
comparison: ComparisonSorter<Item>;
|
|
865
|
-
/**
|
|
866
|
-
* Direction to sort by
|
|
867
|
-
*/
|
|
868
|
-
direction?: SortDirection;
|
|
869
|
-
};
|
|
870
|
-
/**
|
|
871
|
-
* Sorting information for arrays _(using a key)_
|
|
872
|
-
*/
|
|
873
|
-
type ArrayKeySorter<Item extends PlainObject, ItemKey extends keyof Item> = {
|
|
874
|
-
/**
|
|
875
|
-
* Comparator to use when comparing items and values
|
|
876
|
-
*/
|
|
877
|
-
compare?: CompareCallback<Item, Item[ItemKey]>;
|
|
878
|
-
/**
|
|
879
|
-
* Direction to sort by
|
|
880
|
-
*/
|
|
881
|
-
direction?: SortDirection;
|
|
882
|
-
/**
|
|
883
|
-
* Key to sort by
|
|
884
|
-
*/
|
|
885
|
-
key: ItemKey;
|
|
886
|
-
};
|
|
887
|
-
/**
|
|
888
|
-
* Sorters based on keys in an object
|
|
889
|
-
*/
|
|
890
|
-
type ArrayKeySorters<Item extends PlainObject> = { [ItemKey in keyof Item]: ArrayKeySorter<Item, ItemKey> }[keyof Item];
|
|
891
|
-
/**
|
|
892
|
-
* Sorting information for arrays _(using a value callback and built-in comparison)_
|
|
893
|
-
*/
|
|
894
|
-
type ArrayValueSorter<Item> = {
|
|
895
|
-
/**
|
|
896
|
-
* Direction to sort by
|
|
897
|
-
*/
|
|
898
|
-
direction?: SortDirection;
|
|
899
|
-
/**
|
|
900
|
-
* Value to sort by
|
|
901
|
-
*/
|
|
902
|
-
value: (item: Item) => unknown;
|
|
903
|
-
};
|
|
904
|
-
/**
|
|
905
|
-
* Comparator to use when comparing items and values
|
|
906
|
-
*/
|
|
907
|
-
type CompareCallback<Item, Value = CompareCallbackValue<Item>> = (first: Item, firstValue: Value, second: Item, secondValue: Value) => number;
|
|
908
|
-
type CompareCallbackValue<Item> = Item extends Primitive ? Item : unknown;
|
|
909
|
-
/**
|
|
910
|
-
* Callback to use when comparing items and values
|
|
911
|
-
*/
|
|
912
|
-
type ComparisonSorter<Item> = (first: Item, second: Item) => number;
|
|
913
|
-
/**
|
|
914
|
-
* Direction to sort by
|
|
915
|
-
*/
|
|
916
|
-
type SortDirection = 'ascending' | 'descending';
|
|
917
|
-
/**
|
|
918
|
-
* Sorter to use for sorting
|
|
919
|
-
*/
|
|
920
|
-
type Sorter<Item> = Item extends PlainObject ? keyof Item | ArrayComparisonSorter<Item> | ArrayKeySorters<Item> | ArrayValueSorter<Item> | ComparisonSorter<Item> : ArrayComparisonSorter<Item> | ArrayValueSorter<Item> | ComparisonSorter<Item>;
|
|
921
|
-
/**
|
|
922
|
-
* Sort an array of items, using multiple sorters to sort by specific values
|
|
923
|
-
* @param array Array to sort
|
|
924
|
-
* @param sorters Sorters to use for sorting
|
|
925
|
-
* @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
926
|
-
* @returns Sorted array
|
|
927
|
-
*/
|
|
928
|
-
declare function sort<Item>(array: Item[], sorters: Array<Sorter<Item>>, descending?: boolean): Item[];
|
|
929
|
-
/**
|
|
930
|
-
* Sort an array of items, using multiple sorters to sort by specific values
|
|
931
|
-
* @param array Array to sort
|
|
932
|
-
* @param sorter Sorter to use for sorting
|
|
933
|
-
* @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
934
|
-
* @returns Sorted array
|
|
935
|
-
*/
|
|
936
|
-
declare function sort<Item>(array: Item[], sorter: Sorter<Item>, descending?: boolean): Item[];
|
|
937
|
-
/**
|
|
938
|
-
* Sort an array of items
|
|
939
|
-
* @param array Array to sort
|
|
940
|
-
* @param descending Sort in descending order? _(defaults to `false`)_
|
|
941
|
-
* @returns Sorted array
|
|
942
|
-
*/
|
|
943
|
-
declare function sort<Item>(array: Item[], descending?: boolean): Item[];
|
|
944
|
-
declare const SORT_DIRECTION_ASCENDING: SortDirection;
|
|
945
|
-
declare const SORT_DIRECTION_DESCENDING: SortDirection;
|
|
946
|
-
//#endregion
|
|
947
856
|
//#region src/array/splice.d.ts
|
|
948
857
|
/**
|
|
949
858
|
* Adds items into an array at a specific index and removes a specific amount of items
|
|
@@ -1183,6 +1092,121 @@ declare function moveToIndex<Item>(array: Item[], value: Item | Item[], index: n
|
|
|
1183
1092
|
*/
|
|
1184
1093
|
declare function moveToIndex<Item>(array: Item[], value: Item | Item[], index: number): Item[];
|
|
1185
1094
|
//#endregion
|
|
1095
|
+
//#region src/array/sort.d.ts
|
|
1096
|
+
/**
|
|
1097
|
+
* Sorting information for arrays _(using a comparison callback)_
|
|
1098
|
+
*/
|
|
1099
|
+
type ArrayComparisonSorter<Item> = {
|
|
1100
|
+
/**
|
|
1101
|
+
* Callback to use when comparing items and values
|
|
1102
|
+
*/
|
|
1103
|
+
comparison: ComparisonSorter<Item>;
|
|
1104
|
+
/**
|
|
1105
|
+
* Direction to sort by
|
|
1106
|
+
*/
|
|
1107
|
+
direction?: SortDirection;
|
|
1108
|
+
};
|
|
1109
|
+
/**
|
|
1110
|
+
* Sorting information for arrays _(using a key)_
|
|
1111
|
+
*/
|
|
1112
|
+
type ArrayKeySorter<Item extends PlainObject, ItemKey extends keyof Item> = {
|
|
1113
|
+
/**
|
|
1114
|
+
* Comparator to use when comparing items and values
|
|
1115
|
+
*/
|
|
1116
|
+
compare?: CompareCallback<Item, Item[ItemKey]>;
|
|
1117
|
+
/**
|
|
1118
|
+
* Direction to sort by
|
|
1119
|
+
*/
|
|
1120
|
+
direction?: SortDirection;
|
|
1121
|
+
/**
|
|
1122
|
+
* Key to sort by
|
|
1123
|
+
*/
|
|
1124
|
+
key: ItemKey;
|
|
1125
|
+
};
|
|
1126
|
+
/**
|
|
1127
|
+
* Sorters based on keys in an object
|
|
1128
|
+
*/
|
|
1129
|
+
type ArrayKeySorters<Item extends PlainObject> = { [ItemKey in keyof Item]: ArrayKeySorter<Item, ItemKey> }[keyof Item];
|
|
1130
|
+
/**
|
|
1131
|
+
* Sorter to use for sorting
|
|
1132
|
+
*/
|
|
1133
|
+
type ArraySorter<Item> = Item extends PlainObject ? keyof Item | ArrayComparisonSorter<Item> | ArrayKeySorters<Item> | ArrayValueSorter<Item> | ComparisonSorter<Item> : ArrayComparisonSorter<Item> | ArrayValueSorter<Item> | ComparisonSorter<Item>;
|
|
1134
|
+
/**
|
|
1135
|
+
* Sorting information for arrays _(using a value callback and built-in comparison)_
|
|
1136
|
+
*/
|
|
1137
|
+
type ArrayValueSorter<Item> = {
|
|
1138
|
+
/**
|
|
1139
|
+
* Direction to sort by
|
|
1140
|
+
*/
|
|
1141
|
+
direction?: SortDirection;
|
|
1142
|
+
/**
|
|
1143
|
+
* Value to sort by
|
|
1144
|
+
*/
|
|
1145
|
+
value: (item: Item) => unknown;
|
|
1146
|
+
};
|
|
1147
|
+
/**
|
|
1148
|
+
* Comparator to use when comparing items and values
|
|
1149
|
+
*/
|
|
1150
|
+
type CompareCallback<Item, Value = CompareCallbackValue<Item>> = (first: Item, firstValue: Value, second: Item, secondValue: Value) => number;
|
|
1151
|
+
type CompareCallbackValue<Item> = Item extends Primitive ? Item : unknown;
|
|
1152
|
+
/**
|
|
1153
|
+
* Callback to use when comparing items and values
|
|
1154
|
+
*/
|
|
1155
|
+
type ComparisonSorter<Item> = (first: Item, second: Item) => number;
|
|
1156
|
+
/**
|
|
1157
|
+
* Direction to sort by
|
|
1158
|
+
*/
|
|
1159
|
+
type SortDirection = 'ascending' | 'descending';
|
|
1160
|
+
type Sorter<Item> = (array: Item[]) => Item[];
|
|
1161
|
+
/**
|
|
1162
|
+
* Initialize a sort handler with sorters _(and an optional default direction)_
|
|
1163
|
+
* @param sorters Sorters to use for sorting
|
|
1164
|
+
* @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
1165
|
+
* @returns Sort handler
|
|
1166
|
+
*/
|
|
1167
|
+
declare function initializeSort<Item>(sorters: Array<ArraySorter<Item>>, descending?: boolean): Sorter<Item>;
|
|
1168
|
+
/**
|
|
1169
|
+
* Initialize a sort handler with a sorter _(and an optional default direction)_
|
|
1170
|
+
* @param sorter Sorter to use for sorting
|
|
1171
|
+
* @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
1172
|
+
* @returns Sort handler
|
|
1173
|
+
*/
|
|
1174
|
+
declare function initializeSort<Item>(sorter: ArraySorter<Item>, descending?: boolean): Sorter<Item>;
|
|
1175
|
+
/**
|
|
1176
|
+
* Initialize a sort handler _(with an optional default direction)_
|
|
1177
|
+
* @param descending Sort in descending order? _(defaults to `false`)_
|
|
1178
|
+
* @returns Sort handler
|
|
1179
|
+
*/
|
|
1180
|
+
declare function initializeSort<Item>(descending?: boolean): Sorter<Item>;
|
|
1181
|
+
/**
|
|
1182
|
+
* Sort an array of items, using multiple sorters to sort by specific values
|
|
1183
|
+
* @param array Array to sort
|
|
1184
|
+
* @param sorters Sorters to use for sorting
|
|
1185
|
+
* @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
1186
|
+
* @returns Sorted array
|
|
1187
|
+
*/
|
|
1188
|
+
declare function sort<Item>(array: Item[], sorters: Array<ArraySorter<Item>>, descending?: boolean): Item[];
|
|
1189
|
+
/**
|
|
1190
|
+
* Sort an array of items, using multiple sorters to sort by specific values
|
|
1191
|
+
* @param array Array to sort
|
|
1192
|
+
* @param sorter Sorter to use for sorting
|
|
1193
|
+
* @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
1194
|
+
* @returns Sorted array
|
|
1195
|
+
*/
|
|
1196
|
+
declare function sort<Item>(array: Item[], sorter: ArraySorter<Item>, descending?: boolean): Item[];
|
|
1197
|
+
/**
|
|
1198
|
+
* Sort an array of items
|
|
1199
|
+
* @param array Array to sort
|
|
1200
|
+
* @param descending Sort in descending order? _(defaults to `false`)_
|
|
1201
|
+
* @returns Sorted array
|
|
1202
|
+
*/
|
|
1203
|
+
declare function sort<Item>(array: Item[], descending?: boolean): Item[];
|
|
1204
|
+
declare namespace sort {
|
|
1205
|
+
var initialize: typeof initializeSort;
|
|
1206
|
+
}
|
|
1207
|
+
declare const SORT_DIRECTION_ASCENDING: SortDirection;
|
|
1208
|
+
declare const SORT_DIRECTION_DESCENDING: SortDirection;
|
|
1209
|
+
//#endregion
|
|
1186
1210
|
//#region src/array/swap.d.ts
|
|
1187
1211
|
/**
|
|
1188
1212
|
* Swap two smaller arrays within a larger array
|
|
@@ -2956,6 +2980,12 @@ declare function isNumber(value: unknown): value is number;
|
|
|
2956
2980
|
* @returns `true` if the value is a plain object, otherwise `false`
|
|
2957
2981
|
*/
|
|
2958
2982
|
declare function isPlainObject(value: unknown): value is PlainObject;
|
|
2983
|
+
/**
|
|
2984
|
+
* - Is the value a primitive value?
|
|
2985
|
+
* @param value Value to check
|
|
2986
|
+
* @returns `true` if the value matches, otherwise `false`
|
|
2987
|
+
*/
|
|
2988
|
+
declare function isPrimitive(value: unknown): value is Primitive;
|
|
2959
2989
|
/**
|
|
2960
2990
|
* Is the value a typed array?
|
|
2961
2991
|
* @param value Value to check
|
|
@@ -3006,12 +3036,6 @@ declare function isNumerical(value: unknown): value is number | `${number}`;
|
|
|
3006
3036
|
* @returns `true` if the value matches, otherwise `false`
|
|
3007
3037
|
*/
|
|
3008
3038
|
declare function isObject(value: unknown): value is object;
|
|
3009
|
-
/**
|
|
3010
|
-
* - Is the value a primitive value?
|
|
3011
|
-
* @param value Value to check
|
|
3012
|
-
* @returns `true` if the value matches, otherwise `false`
|
|
3013
|
-
*/
|
|
3014
|
-
declare function isPrimitive(value: unknown): value is Primitive;
|
|
3015
3039
|
//#endregion
|
|
3016
3040
|
//#region src/logger.d.ts
|
|
3017
3041
|
declare class Logger {
|
|
@@ -4327,4 +4351,4 @@ declare class SizedSet<Value = unknown> extends Set<Value> {
|
|
|
4327
4351
|
get(value: Value, update?: boolean): Value | undefined;
|
|
4328
4352
|
}
|
|
4329
4353
|
//#endregion
|
|
4330
|
-
export { AnyResult, ArrayComparisonSorter, ArrayKeySorter, ArrayOrPlainObject, ArrayPosition, ArrayValueSorter, Asserter, AttemptFlow, AttemptFlowPromise, type Beacon, type BeaconOptions, BuiltIns, CancelableCallback, CancelablePromise, type Color, Constructor, DiffOptions, DiffResult, DiffValue, EqualOptions, Err, EventPosition, ExtendedErr, ExtendedResult, Flow, FlowPromise, FulfilledPromise, GenericAsyncCallback, GenericCallback, type HSLAColor, type HSLColor, HasValue, Key, KeyedValue, type Logger, type Memoized, type MemoizedOptions, MergeOptions, Merger, NestedArray, NestedKeys, NestedPartial, NestedValue, NestedValues, NumericalKeys, NumericalValues, type Observable, type Observer, Ok, OnceAsyncCallback, OnceCallback, PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_ERROR_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_RESULT, PROMISE_MESSAGE_EXPECTATION_TIMED, PROMISE_MESSAGE_TIMEOUT, PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED, PlainObject, Primitive, PromiseData, PromiseHandlers, PromiseOptions, PromiseParameters, PromiseStrategy, PromiseTimeoutError, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped, PromisesValue, PromisesValues, type Queue, QueueError, type QueueOptions, type Queued, type RGBAColor, type RGBColor, RejectedPromise, RequiredKeys, Result, ResultMatch, RetryError, RetryOptions, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, Simplify, SizedMap, SizedSet, Smushed, SortDirection, type Subscription, TemplateOptions, type Time, ToString, TypedArray, Unsmushed, UnwrapValue, assert, attempt, attemptFlow, attemptPipe, attemptPromise, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, count, debounce, delay, diff, difference, drop, endsWith, endsWithArray, equal, error, exists, filter, find, flatten, floor, flow, fromQuery, toPromise as fromResult, toPromise, getArray, getArrayPosition, getColor, getError, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getTimedPromise, getUuid, getValue, groupBy, handleResult, hasValue, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, ignoreKey, includes, includesArray, indexOf, indexOfArray, insert, intersection, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isInstanceOf, isKey, isNonNullable, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, lowerCase, matchResult, max, median, memoize, merge, min, move, noop, ok, omit, once, parse, partition, pascalCase, pick, pipe, promises, push, queue, range, retry, rgbToHex, rgbToHsl, rgbToHsla, round, select, setValue, settlePromise, shuffle, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toQuery, toRecord, toResult, toSet, toggle, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };
|
|
4354
|
+
export { AnyResult, ArrayComparisonSorter, ArrayKeySorter, ArrayOrPlainObject, ArrayPosition, ArrayValueSorter, Asserter, AttemptFlow, AttemptFlowPromise, type Beacon, type BeaconOptions, BuiltIns, CancelableCallback, CancelablePromise, type Color, Constructor, DiffOptions, DiffResult, DiffValue, EqualOptions, Err, EventPosition, ExtendedErr, ExtendedResult, Flow, FlowPromise, FulfilledPromise, GenericAsyncCallback, GenericCallback, type HSLAColor, type HSLColor, HasValue, Key, KeyedValue, type Logger, type Memoized, type MemoizedOptions, MergeOptions, Merger, NestedArray, NestedKeys, NestedPartial, NestedValue, NestedValues, NumericalKeys, NumericalValues, type Observable, type Observer, Ok, OnceAsyncCallback, OnceCallback, PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_ERROR_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_RESULT, PROMISE_MESSAGE_EXPECTATION_TIMED, PROMISE_MESSAGE_TIMEOUT, PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED, PlainObject, Primitive, PromiseData, PromiseHandlers, PromiseOptions, PromiseParameters, PromiseStrategy, PromiseTimeoutError, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped, PromisesValue, PromisesValues, type Queue, QueueError, type QueueOptions, type Queued, type RGBAColor, type RGBColor, RejectedPromise, RequiredKeys, Result, ResultMatch, RetryError, RetryOptions, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, Simplify, SizedMap, SizedSet, Smushed, SortDirection, Sorter, type Subscription, TemplateOptions, type Time, ToString, TypedArray, Unsmushed, UnwrapValue, assert, attempt, attemptFlow, attemptPipe, attemptPromise, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, count, debounce, delay, diff, difference, drop, endsWith, endsWithArray, equal, error, exists, filter, find, flatten, floor, flow, fromQuery, toPromise as fromResult, toPromise, getArray, getArrayPosition, getColor, getError, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getTimedPromise, getUuid, getValue, groupBy, handleResult, hasValue, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, ignoreKey, includes, includesArray, indexOf, indexOfArray, insert, intersection, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isInstanceOf, isKey, isNonNullable, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, lowerCase, matchResult, max, median, memoize, merge, min, move, noop, ok, omit, once, parse, partition, pascalCase, pick, pipe, promises, push, queue, range, retry, rgbToHex, rgbToHsl, rgbToHsla, round, select, setValue, settlePromise, shuffle, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toQuery, toRecord, toResult, toSet, toggle, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };
|