@mll-lab/js-utils 2.18.0 → 2.19.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 +8 -0
- package/dist/index.common.js +15 -0
- package/dist/index.common.js.map +1 -1
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9491,6 +9491,20 @@ function sortByArray(subject, recipe) {
|
|
|
9491
9491
|
}
|
|
9492
9492
|
return lodash.sortBy(subject, (value) => recipe.indexOf(value));
|
|
9493
9493
|
}
|
|
9494
|
+
/**
|
|
9495
|
+
* Takes a function that maps the values to sort and returns a compare function
|
|
9496
|
+
* using `String.prototype.localeCompare`, usable in `Array.sort` or similar APIs.
|
|
9497
|
+
*
|
|
9498
|
+
* null, undefined and the empty string are not distinguished and first in sort order.
|
|
9499
|
+
*/
|
|
9500
|
+
function makeStringCompareFn(map) {
|
|
9501
|
+
return (a, b) => {
|
|
9502
|
+
var _a, _b;
|
|
9503
|
+
const mappedA = (_a = map(a)) !== null && _a !== void 0 ? _a : '';
|
|
9504
|
+
const mappedB = (_b = map(b)) !== null && _b !== void 0 ? _b : '';
|
|
9505
|
+
return mappedA.localeCompare(mappedB);
|
|
9506
|
+
};
|
|
9507
|
+
}
|
|
9494
9508
|
|
|
9495
9509
|
function toInteger(dirtyNumber) {
|
|
9496
9510
|
if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
|
|
@@ -15484,6 +15498,7 @@ exports.isURL = isURL;
|
|
|
15484
15498
|
exports.isWord = isWord;
|
|
15485
15499
|
exports.joinNonEmpty = joinNonEmpty;
|
|
15486
15500
|
exports.last = last;
|
|
15501
|
+
exports.makeStringCompareFn = makeStringCompareFn;
|
|
15487
15502
|
exports.mapSequentially = mapSequentially;
|
|
15488
15503
|
exports.parseDate = parseDate;
|
|
15489
15504
|
exports.parseDotlessDate = parseDotlessDate;
|