@mll-lab/js-utils 2.37.0 → 2.38.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.d.ts +5 -0
- package/dist/index.common.js +12 -0
- package/dist/index.common.js.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -9583,6 +9583,17 @@ function makeNumberCompareFn(map, fallbackValue = 0) {
|
|
|
9583
9583
|
return mappedA - mappedB;
|
|
9584
9584
|
};
|
|
9585
9585
|
}
|
|
9586
|
+
/**
|
|
9587
|
+
* Takes a function that maps the values to sort to booleans and returns a compare function that puts `false` before `true`.
|
|
9588
|
+
* Usable in `Array.toSorted` or similar APIs.
|
|
9589
|
+
*/
|
|
9590
|
+
function makeBooleanCompareFn(map) {
|
|
9591
|
+
return (a, b) => {
|
|
9592
|
+
const mappedA = map(a);
|
|
9593
|
+
const mappedB = map(b);
|
|
9594
|
+
return Number(mappedA) - Number(mappedB);
|
|
9595
|
+
};
|
|
9596
|
+
}
|
|
9586
9597
|
/**
|
|
9587
9598
|
* Returns a compare function for values that are string, null or undefined,
|
|
9588
9599
|
* using `String.prototype.localeCompare`, usable in `Array.toSorted` or similar APIs.
|
|
@@ -16330,6 +16341,7 @@ exports.isZeroish = isZeroish;
|
|
|
16330
16341
|
exports.joinNonEmpty = joinNonEmpty;
|
|
16331
16342
|
exports.last = last;
|
|
16332
16343
|
exports.localeCompareStrings = localeCompareStrings;
|
|
16344
|
+
exports.makeBooleanCompareFn = makeBooleanCompareFn;
|
|
16333
16345
|
exports.makeNumberCompareFn = makeNumberCompareFn;
|
|
16334
16346
|
exports.makeStringCompareFn = makeStringCompareFn;
|
|
16335
16347
|
exports.mapSequentially = mapSequentially;
|