1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | function ifElse(condition, then, otherwise) {
|
5 | return condition ? then : otherwise;
|
6 | }
|
7 | exports.ifElse = ifElse;
|
8 | function flatten(array) {
|
9 | return array.reduce((all, item) => {
|
10 | if (!item) {
|
11 | return all;
|
12 | }
|
13 | return Array.isArray(item) ? [...all, ...flatten(item)] : [...all, item];
|
14 | }, []);
|
15 | }
|
16 | exports.flatten = flatten;
|
17 | function removeEmptyValues(obj) {
|
18 | return Object.keys(obj).reduce((all, key) => {
|
19 | const value = obj[key];
|
20 | if (value == null || Array.isArray(value) && value.length === 0) {
|
21 | return all;
|
22 | }
|
23 | return Object.assign({}, all, { [key]: value });
|
24 | }, {});
|
25 | }
|
26 | exports.removeEmptyValues = removeEmptyValues;
|
27 | function msToMinutesAndSeconds(ms) {
|
28 | let minutes = Math.floor(ms / 1000 / 60);
|
29 | let seconds = Math.round(ms / 1000 % 60);
|
30 | if (seconds === 60) {
|
31 | minutes += 1;
|
32 | seconds = 0;
|
33 | }
|
34 | if (minutes === 0) {
|
35 | return `${seconds}s`;
|
36 | }
|
37 | if (seconds < 10) {
|
38 | return `${minutes}m0${seconds}s`;
|
39 | }
|
40 | return `${minutes}m${seconds}s`;
|
41 | }
|
42 | exports.msToMinutesAndSeconds = msToMinutesAndSeconds; |
\ | No newline at end of file |