@mll-lab/js-utils 2.13.0 → 2.15.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/file.d.ts +4 -0
- package/dist/file.test.d.ts +1 -0
- package/dist/index.common.js +96 -9
- package/dist/index.common.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +96 -9
- package/dist/index.js.map +1 -1
- package/dist/predicates.d.ts +1 -1
- package/dist/promise.d.ts +8 -0
- package/dist/promise.test.d.ts +1 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,11 @@ export * from './array';
|
|
|
2
2
|
export * from './date';
|
|
3
3
|
export * from './device';
|
|
4
4
|
export * from './error';
|
|
5
|
+
export * from './file';
|
|
5
6
|
export * from './germanNumber';
|
|
6
7
|
export * from './number';
|
|
7
8
|
export * from './pluralize';
|
|
8
9
|
export * from './predicates';
|
|
10
|
+
export * from './promise';
|
|
9
11
|
export * from './string';
|
|
10
12
|
export * from './style';
|
package/dist/index.js
CHANGED
|
@@ -15187,6 +15187,19 @@ function hasMessage(error) {
|
|
|
15187
15187
|
return typeof error === 'object' && error !== null && 'message' in error;
|
|
15188
15188
|
}
|
|
15189
15189
|
|
|
15190
|
+
/**
|
|
15191
|
+
* Triggers a file download in the browser.
|
|
15192
|
+
*/
|
|
15193
|
+
function downloadBlob(blob, filename) {
|
|
15194
|
+
const link = document.createElement('a');
|
|
15195
|
+
link.href = URL.createObjectURL(blob);
|
|
15196
|
+
link.download = filename;
|
|
15197
|
+
link.style.display = 'none';
|
|
15198
|
+
document.body.appendChild(link);
|
|
15199
|
+
link.click();
|
|
15200
|
+
document.body.removeChild(link);
|
|
15201
|
+
}
|
|
15202
|
+
|
|
15190
15203
|
function __rest(s, e) {
|
|
15191
15204
|
var t = {};
|
|
15192
15205
|
|
|
@@ -15199,6 +15212,37 @@ function __rest(s, e) {
|
|
|
15199
15212
|
}
|
|
15200
15213
|
return t;
|
|
15201
15214
|
}
|
|
15215
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
15216
|
+
function adopt(value) {
|
|
15217
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
15218
|
+
resolve(value);
|
|
15219
|
+
});
|
|
15220
|
+
}
|
|
15221
|
+
|
|
15222
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15223
|
+
function fulfilled(value) {
|
|
15224
|
+
try {
|
|
15225
|
+
step(generator.next(value));
|
|
15226
|
+
} catch (e) {
|
|
15227
|
+
reject(e);
|
|
15228
|
+
}
|
|
15229
|
+
}
|
|
15230
|
+
|
|
15231
|
+
function rejected(value) {
|
|
15232
|
+
try {
|
|
15233
|
+
step(generator["throw"](value));
|
|
15234
|
+
} catch (e) {
|
|
15235
|
+
reject(e);
|
|
15236
|
+
}
|
|
15237
|
+
}
|
|
15238
|
+
|
|
15239
|
+
function step(result) {
|
|
15240
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
15241
|
+
}
|
|
15242
|
+
|
|
15243
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15244
|
+
});
|
|
15245
|
+
}
|
|
15202
15246
|
|
|
15203
15247
|
const GERMAN_THOUSAND_SEPARATOR = '.';
|
|
15204
15248
|
const GERMAN_DECIMAL_SEPARATOR = ',';
|
|
@@ -15275,20 +15319,28 @@ function pluralize(amount, singular, plural) {
|
|
|
15275
15319
|
function isString(value) {
|
|
15276
15320
|
return typeof value === 'string';
|
|
15277
15321
|
}
|
|
15278
|
-
const isAlphanumeric =
|
|
15322
|
+
const isAlphanumeric = function isAlphanumeric(value) {
|
|
15323
|
+
return isString(value) && /^[A-Za-z0-9]+$/.test(value);
|
|
15324
|
+
};
|
|
15279
15325
|
/**
|
|
15280
15326
|
* BSNR (Betriebsstättennummer) ist eine eindeutige Zuordnung von Leistungen zu dem entsprechenden Ort der Leistungserbringung ermöglicht,
|
|
15281
15327
|
* für alle vertrags(zahn)ärztlichen Leistungserbringer gültig
|
|
15282
15328
|
* und klar abzugrenzen vom Institutskennzeichen (IK-Nummer) eines Krankenhauses.
|
|
15283
15329
|
*/
|
|
15284
|
-
const isBSNR =
|
|
15330
|
+
const isBSNR = function isBSNR(value) {
|
|
15331
|
+
return isString(value) && /^\d{9}$/.test(value);
|
|
15332
|
+
};
|
|
15285
15333
|
// Taken from https://emailregex.com
|
|
15286
15334
|
const EMAIL_REGEX =
|
|
15287
15335
|
// eslint-disable-next-line no-useless-escape
|
|
15288
15336
|
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
15289
|
-
const isEmail =
|
|
15290
|
-
|
|
15291
|
-
|
|
15337
|
+
const isEmail = function isEmail(value) {
|
|
15338
|
+
return isString(value) && EMAIL_REGEX.test(value);
|
|
15339
|
+
};
|
|
15340
|
+
const isOnlyDigits = function isOnlyDigits(value) {
|
|
15341
|
+
return isString(value) && /^\d+$/.test(value);
|
|
15342
|
+
};
|
|
15343
|
+
const isURL = function isURL(value) {
|
|
15292
15344
|
if (!isString(value)) {
|
|
15293
15345
|
return false;
|
|
15294
15346
|
}
|
|
@@ -15302,11 +15354,43 @@ const isURL = (value) => {
|
|
|
15302
15354
|
return false;
|
|
15303
15355
|
}
|
|
15304
15356
|
};
|
|
15305
|
-
const isWord =
|
|
15306
|
-
|
|
15307
|
-
|
|
15308
|
-
function
|
|
15357
|
+
const isWord = function isWord(value) {
|
|
15358
|
+
return isString(value) && /^[\w-]+$/.test(value);
|
|
15359
|
+
};
|
|
15360
|
+
const isLabId = function isLabId(value) {
|
|
15361
|
+
return isString(value) && /^\d{2}-\d{6}$/.test(value);
|
|
15362
|
+
};
|
|
15363
|
+
const isRackBarcode = function isRackBarcode(value) {
|
|
15364
|
+
return isString(value) && /^[A-Z]{2}\d{8}$/.test(value);
|
|
15365
|
+
};
|
|
15366
|
+
const isNotNullish = function isNotNullish(value) {
|
|
15309
15367
|
return value != null;
|
|
15368
|
+
};
|
|
15369
|
+
|
|
15370
|
+
/**
|
|
15371
|
+
* Call an array of promises in order, waiting for each promise to resolve before calling the next.
|
|
15372
|
+
*/
|
|
15373
|
+
function callSequentially(promises) {
|
|
15374
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15375
|
+
return promises.reduce((promise, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
15376
|
+
yield promise;
|
|
15377
|
+
return callback();
|
|
15378
|
+
}), Promise.resolve());
|
|
15379
|
+
});
|
|
15380
|
+
}
|
|
15381
|
+
/**
|
|
15382
|
+
* Map an array using an asynchronous callback function, waiting for each promise to resolve before calling the next.
|
|
15383
|
+
*/
|
|
15384
|
+
function mapSequentially(array, callbackFn) {
|
|
15385
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15386
|
+
const results = [];
|
|
15387
|
+
yield array.reduce((promise, value) => __awaiter(this, void 0, void 0, function* () {
|
|
15388
|
+
yield promise;
|
|
15389
|
+
const result = yield callbackFn(value);
|
|
15390
|
+
results.push(result);
|
|
15391
|
+
}), Promise.resolve());
|
|
15392
|
+
return results;
|
|
15393
|
+
});
|
|
15310
15394
|
}
|
|
15311
15395
|
|
|
15312
15396
|
function includesIgnoreCase(needle, haystack) {
|
|
@@ -15352,7 +15436,9 @@ exports.GERMAN_THOUSAND_SEPARATOR = GERMAN_THOUSAND_SEPARATOR;
|
|
|
15352
15436
|
exports.ISO_DATE_FORMAT = ISO_DATE_FORMAT;
|
|
15353
15437
|
exports.ISO_DATE_TIME_FORMAT = ISO_DATE_TIME_FORMAT;
|
|
15354
15438
|
exports.SECONDLESS_DATE_TIME_FORMAT = SECONDLESS_DATE_TIME_FORMAT;
|
|
15439
|
+
exports.callSequentially = callSequentially;
|
|
15355
15440
|
exports.containSameValues = containSameValues;
|
|
15441
|
+
exports.downloadBlob = downloadBlob;
|
|
15356
15442
|
exports.errorMessage = errorMessage;
|
|
15357
15443
|
exports.firstDecimalDigit = firstDecimalDigit;
|
|
15358
15444
|
exports.firstLine = firstLine;
|
|
@@ -15383,6 +15469,7 @@ exports.isURL = isURL;
|
|
|
15383
15469
|
exports.isWord = isWord;
|
|
15384
15470
|
exports.joinNonEmpty = joinNonEmpty;
|
|
15385
15471
|
exports.last = last;
|
|
15472
|
+
exports.mapSequentially = mapSequentially;
|
|
15386
15473
|
exports.parseDate = parseDate;
|
|
15387
15474
|
exports.parseDotlessDate = parseDotlessDate;
|
|
15388
15475
|
exports.parseGermanDate = parseGermanDate;
|