@mll-lab/js-utils 2.18.0 → 2.20.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/index.js CHANGED
@@ -9435,6 +9435,9 @@ root._=_;}}).call(commonjsGlobal);});
9435
9435
  function isNonEmptyArray(value) {
9436
9436
  return value.length > 0;
9437
9437
  }
9438
+ function isEmptyArray(value) {
9439
+ return value instanceof Array && value.length === 0;
9440
+ }
9438
9441
  /**
9439
9442
  * Return a new array that does not contain the item at the specified index.
9440
9443
  */
@@ -9491,6 +9494,20 @@ function sortByArray(subject, recipe) {
9491
9494
  }
9492
9495
  return lodash.sortBy(subject, (value) => recipe.indexOf(value));
9493
9496
  }
9497
+ /**
9498
+ * Takes a function that maps the values to sort and returns a compare function
9499
+ * using `String.prototype.localeCompare`, usable in `Array.sort` or similar APIs.
9500
+ *
9501
+ * null, undefined and the empty string are not distinguished and first in sort order.
9502
+ */
9503
+ function makeStringCompareFn(map) {
9504
+ return (a, b) => {
9505
+ var _a, _b;
9506
+ const mappedA = (_a = map(a)) !== null && _a !== void 0 ? _a : '';
9507
+ const mappedB = (_b = map(b)) !== null && _b !== void 0 ? _b : '';
9508
+ return mappedA.localeCompare(mappedB);
9509
+ };
9510
+ }
9494
9511
 
9495
9512
  function toInteger(dirtyNumber) {
9496
9513
  if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
@@ -15470,6 +15487,7 @@ exports.insertIf = insertIf;
15470
15487
  exports.isAlphanumeric = isAlphanumeric;
15471
15488
  exports.isBSNR = isBSNR;
15472
15489
  exports.isEmail = isEmail;
15490
+ exports.isEmptyArray = isEmptyArray;
15473
15491
  exports.isFuture = isFuture;
15474
15492
  exports.isLabId = isLabId;
15475
15493
  exports.isMobileDevice = isMobileDevice;
@@ -15484,6 +15502,7 @@ exports.isURL = isURL;
15484
15502
  exports.isWord = isWord;
15485
15503
  exports.joinNonEmpty = joinNonEmpty;
15486
15504
  exports.last = last;
15505
+ exports.makeStringCompareFn = makeStringCompareFn;
15487
15506
  exports.mapSequentially = mapSequentially;
15488
15507
  exports.parseDate = parseDate;
15489
15508
  exports.parseDotlessDate = parseDotlessDate;