@mll-lab/js-utils 2.17.1 → 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/date.d.ts +1 -0
- package/dist/index.common.js +19 -0
- package/dist/index.common.js.map +1 -1
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/array.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Maybe } from './types';
|
|
1
2
|
export declare type NonEmptyArray<T> = Array<T> & {
|
|
2
3
|
0: T;
|
|
3
4
|
};
|
|
@@ -40,3 +41,10 @@ export declare function toggleElement<T>(array: Array<T>, element: T): Array<T>;
|
|
|
40
41
|
* returns sorted array [Jan, Mar, Dec]
|
|
41
42
|
*/
|
|
42
43
|
export declare function sortByArray<T extends string | number>(subject: Array<T>, recipe: Array<T>): Array<T>;
|
|
44
|
+
/**
|
|
45
|
+
* Takes a function that maps the values to sort and returns a compare function
|
|
46
|
+
* using `String.prototype.localeCompare`, usable in `Array.sort` or similar APIs.
|
|
47
|
+
*
|
|
48
|
+
* null, undefined and the empty string are not distinguished and first in sort order.
|
|
49
|
+
*/
|
|
50
|
+
export declare function makeStringCompareFn<TSortable>(map: (sortable: TSortable) => Maybe<string>): (a: TSortable, b: TSortable) => number;
|
package/dist/date.d.ts
CHANGED
|
@@ -23,3 +23,4 @@ export declare function formatIsoDateTime(date: Date | string | number): string;
|
|
|
23
23
|
export declare const DOTLESS_DATE_FORMAT = "yMMdd";
|
|
24
24
|
export declare function parseDotlessDate(value: string): Date | null;
|
|
25
25
|
export declare function formatDotlessDate(date: Date | string | number): string;
|
|
26
|
+
export declare function formatGermanTimeHourMinute(date: string): string;
|
package/dist/index.common.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) {
|
|
@@ -15161,6 +15175,9 @@ function parseDotlessDate(value) {
|
|
|
15161
15175
|
function formatDotlessDate(date) {
|
|
15162
15176
|
return format(date, DOTLESS_DATE_FORMAT, { locale: de$1 });
|
|
15163
15177
|
}
|
|
15178
|
+
function formatGermanTimeHourMinute(date) {
|
|
15179
|
+
return format(date, 'HH:mm');
|
|
15180
|
+
}
|
|
15164
15181
|
|
|
15165
15182
|
/**
|
|
15166
15183
|
* Detects if a mobile device is used
|
|
@@ -15458,6 +15475,7 @@ exports.formatGerman = formatGerman;
|
|
|
15458
15475
|
exports.formatGermanDateTime = formatGermanDateTime;
|
|
15459
15476
|
exports.formatGermanDotlessDate = formatGermanDotlessDate;
|
|
15460
15477
|
exports.formatGermanNumber = formatGermanNumber;
|
|
15478
|
+
exports.formatGermanTimeHourMinute = formatGermanTimeHourMinute;
|
|
15461
15479
|
exports.formatIsoDate = formatIsoDate;
|
|
15462
15480
|
exports.formatIsoDateTime = formatIsoDateTime;
|
|
15463
15481
|
exports.formatSecondlessDateTime = formatSecondlessDateTime;
|
|
@@ -15480,6 +15498,7 @@ exports.isURL = isURL;
|
|
|
15480
15498
|
exports.isWord = isWord;
|
|
15481
15499
|
exports.joinNonEmpty = joinNonEmpty;
|
|
15482
15500
|
exports.last = last;
|
|
15501
|
+
exports.makeStringCompareFn = makeStringCompareFn;
|
|
15483
15502
|
exports.mapSequentially = mapSequentially;
|
|
15484
15503
|
exports.parseDate = parseDate;
|
|
15485
15504
|
exports.parseDotlessDate = parseDotlessDate;
|