@mll-lab/js-utils 2.5.0 → 2.8.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.common.js +29 -9
- package/dist/index.common.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +29 -9
- package/dist/index.js.map +1 -1
- package/dist/{round.d.ts → number.d.ts} +1 -0
- package/dist/{round.test.d.ts → number.test.d.ts} +0 -0
- package/dist/predicates.d.ts +1 -0
- package/dist/string.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.common.js
CHANGED
|
@@ -15128,6 +15128,27 @@ function hasMessage(error) {
|
|
|
15128
15128
|
return typeof error === 'object' && error !== null && 'message' in error;
|
|
15129
15129
|
}
|
|
15130
15130
|
|
|
15131
|
+
/**
|
|
15132
|
+
* Round a number to a given number of decimal places.
|
|
15133
|
+
*
|
|
15134
|
+
* https://gist.github.com/djD-REK/2e347f5532bb22310daf450f03ec6ad8
|
|
15135
|
+
*/
|
|
15136
|
+
function round(number, decimalPlaces) {
|
|
15137
|
+
const factorOfTen = Math.pow(10, decimalPlaces);
|
|
15138
|
+
return Math.round(number * factorOfTen) / factorOfTen;
|
|
15139
|
+
}
|
|
15140
|
+
function firstDecimalDigit(number) {
|
|
15141
|
+
if (number % 1 === 0) {
|
|
15142
|
+
return 0;
|
|
15143
|
+
}
|
|
15144
|
+
const regExp = /\d*\.(\d)/;
|
|
15145
|
+
const regExpMatchArray = number.toString().match(regExp);
|
|
15146
|
+
if (regExpMatchArray === null) {
|
|
15147
|
+
throw new Error(`Invalid number for regex matching: ${number}`);
|
|
15148
|
+
}
|
|
15149
|
+
return Number(regExpMatchArray[1]);
|
|
15150
|
+
}
|
|
15151
|
+
|
|
15131
15152
|
function pluralize(amount, singular, plural) {
|
|
15132
15153
|
if (amount === 1) {
|
|
15133
15154
|
return singular;
|
|
@@ -15167,15 +15188,8 @@ const isURL = (value) => {
|
|
|
15167
15188
|
const isWord = (value) => isString(value) && /^[\w-]+$/.test(value);
|
|
15168
15189
|
const isLabId = (value) => isString(value) && /^\d{2}-\d{6}$/.test(value);
|
|
15169
15190
|
const isRackBarcode = (value) => isString(value) && /^[A-Z]{2}\d{8}$/.test(value);
|
|
15170
|
-
|
|
15171
|
-
|
|
15172
|
-
* Round a number to a given number of decimal places.
|
|
15173
|
-
*
|
|
15174
|
-
* https://gist.github.com/djD-REK/2e347f5532bb22310daf450f03ec6ad8
|
|
15175
|
-
*/
|
|
15176
|
-
function round(number, decimalPlaces) {
|
|
15177
|
-
const factorOfTen = Math.pow(10, decimalPlaces);
|
|
15178
|
-
return Math.round(number * factorOfTen) / factorOfTen;
|
|
15191
|
+
function isNotNullish(value) {
|
|
15192
|
+
return value != null;
|
|
15179
15193
|
}
|
|
15180
15194
|
|
|
15181
15195
|
function includesIgnoreCase(needle, haystack) {
|
|
@@ -15187,6 +15201,9 @@ function includesIgnoreCase(needle, haystack) {
|
|
|
15187
15201
|
function firstLine(multilineText) {
|
|
15188
15202
|
return multilineText.split('\n', 1)[0];
|
|
15189
15203
|
}
|
|
15204
|
+
function joinNonEmpty(maybeStrings, separator) {
|
|
15205
|
+
return maybeStrings.filter(Boolean).join(separator);
|
|
15206
|
+
}
|
|
15190
15207
|
|
|
15191
15208
|
exports.DOTLESS_DATE_FORMAT = DOTLESS_DATE_FORMAT;
|
|
15192
15209
|
exports.EMAIL_REGEX = EMAIL_REGEX;
|
|
@@ -15199,6 +15216,7 @@ exports.ISO_DATE_TIME_FORMAT = ISO_DATE_TIME_FORMAT;
|
|
|
15199
15216
|
exports.SECONDLESS_DATE_TIME_FORMAT = SECONDLESS_DATE_TIME_FORMAT;
|
|
15200
15217
|
exports.containSameValues = containSameValues;
|
|
15201
15218
|
exports.errorMessage = errorMessage;
|
|
15219
|
+
exports.firstDecimalDigit = firstDecimalDigit;
|
|
15202
15220
|
exports.firstLine = firstLine;
|
|
15203
15221
|
exports.formatDotlessDate = formatDotlessDate;
|
|
15204
15222
|
exports.formatGerman = formatGerman;
|
|
@@ -15215,12 +15233,14 @@ exports.isEmail = isEmail;
|
|
|
15215
15233
|
exports.isFuture = isFuture;
|
|
15216
15234
|
exports.isLabId = isLabId;
|
|
15217
15235
|
exports.isNonEmptyArray = isNonEmptyArray;
|
|
15236
|
+
exports.isNotNullish = isNotNullish;
|
|
15218
15237
|
exports.isOnlyDigits = isOnlyDigits;
|
|
15219
15238
|
exports.isRackBarcode = isRackBarcode;
|
|
15220
15239
|
exports.isString = isString;
|
|
15221
15240
|
exports.isToday = isToday;
|
|
15222
15241
|
exports.isURL = isURL;
|
|
15223
15242
|
exports.isWord = isWord;
|
|
15243
|
+
exports.joinNonEmpty = joinNonEmpty;
|
|
15224
15244
|
exports.last = last;
|
|
15225
15245
|
exports.parseDate = parseDate;
|
|
15226
15246
|
exports.parseDotlessDate = parseDotlessDate;
|