@mll-lab/js-utils 2.31.0 → 2.32.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 +2 -0
- package/dist/index.common.js +8 -0
- package/dist/index.common.js.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/array.d.ts
CHANGED
|
@@ -56,3 +56,5 @@ export declare function makeStringCompareFn<TSortable>(map: (sortable: TSortable
|
|
|
56
56
|
* The empty string is first in sort order.
|
|
57
57
|
*/
|
|
58
58
|
export declare function localeCompareStrings(a: string, b: string): number;
|
|
59
|
+
/** If the given array contains exactly one item, return that, otherwise null. */
|
|
60
|
+
export declare function soleItem<T>(array: Maybe<Array<T>>): T | null;
|
package/dist/index.common.js
CHANGED
|
@@ -9527,6 +9527,13 @@ function makeStringCompareFn(map) {
|
|
|
9527
9527
|
function localeCompareStrings(a, b) {
|
|
9528
9528
|
return a.localeCompare(b);
|
|
9529
9529
|
}
|
|
9530
|
+
/** If the given array contains exactly one item, return that, otherwise null. */
|
|
9531
|
+
function soleItem(array) {
|
|
9532
|
+
if (!array || array.length !== 1) {
|
|
9533
|
+
return null;
|
|
9534
|
+
}
|
|
9535
|
+
return array[0];
|
|
9536
|
+
}
|
|
9530
9537
|
|
|
9531
9538
|
/**
|
|
9532
9539
|
* @name toDate
|
|
@@ -15928,6 +15935,7 @@ exports.pick = pick;
|
|
|
15928
15935
|
exports.pluralize = pluralize;
|
|
15929
15936
|
exports.pxToNumber = pxToNumber;
|
|
15930
15937
|
exports.round = round;
|
|
15938
|
+
exports.soleItem = soleItem;
|
|
15931
15939
|
exports.sortByArray = sortByArray;
|
|
15932
15940
|
exports.toggleElement = toggleElement;
|
|
15933
15941
|
exports.withoutIndex = withoutIndex;
|