@augment-vir/common 23.1.1 → 23.2.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.
|
@@ -38,12 +38,12 @@ function removeCommasFromNumberString(numberString) {
|
|
|
38
38
|
}
|
|
39
39
|
exports.removeCommasFromNumberString = removeCommasFromNumberString;
|
|
40
40
|
/** Collapse all consecutive white space into just one space and trim surrounding whitespace. */
|
|
41
|
-
function collapseWhiteSpace(input) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
function collapseWhiteSpace(input, { keepNewLines } = {}) {
|
|
42
|
+
const newLineReplacement = keepNewLines
|
|
43
|
+
? input.replace(/[\s\n]*\n+[\s\n]*/g, '\n')
|
|
44
|
+
: // sometimes \n isn't included in \s
|
|
45
|
+
input.replace(/\n/g, ' ');
|
|
46
|
+
return newLineReplacement.trim().replace(/\s{2,}/g, ' ');
|
|
47
47
|
}
|
|
48
48
|
exports.collapseWhiteSpace = collapseWhiteSpace;
|
|
49
49
|
/** Same as String.prototype.split but includes the delimiter to split by in the output array. */
|
|
@@ -32,12 +32,12 @@ export function removeCommasFromNumberString(numberString) {
|
|
|
32
32
|
return numberString.replace(/,/g, '');
|
|
33
33
|
}
|
|
34
34
|
/** Collapse all consecutive white space into just one space and trim surrounding whitespace. */
|
|
35
|
-
export function collapseWhiteSpace(input) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
export function collapseWhiteSpace(input, { keepNewLines } = {}) {
|
|
36
|
+
const newLineReplacement = keepNewLines
|
|
37
|
+
? input.replace(/[\s\n]*\n+[\s\n]*/g, '\n')
|
|
38
|
+
: // sometimes \n isn't included in \s
|
|
39
|
+
input.replace(/\n/g, ' ');
|
|
40
|
+
return newLineReplacement.trim().replace(/\s{2,}/g, ' ');
|
|
41
41
|
}
|
|
42
42
|
/** Same as String.prototype.split but includes the delimiter to split by in the output array. */
|
|
43
43
|
export function splitIncludeSplit(original, splitterInput, caseSensitive) {
|
|
@@ -14,7 +14,9 @@ export declare function removeAnsiEscapeCodes(input: string): string;
|
|
|
14
14
|
export declare const removeColor: typeof removeAnsiEscapeCodes;
|
|
15
15
|
export declare function removeCommasFromNumberString(numberString: string): string;
|
|
16
16
|
/** Collapse all consecutive white space into just one space and trim surrounding whitespace. */
|
|
17
|
-
export declare function collapseWhiteSpace(input: string
|
|
17
|
+
export declare function collapseWhiteSpace(input: string, { keepNewLines }?: PartialAndUndefined<{
|
|
18
|
+
keepNewLines: boolean;
|
|
19
|
+
}>): string;
|
|
18
20
|
/** Same as String.prototype.split but includes the delimiter to split by in the output array. */
|
|
19
21
|
export declare function splitIncludeSplit(original: string, splitterInput: string | RegExp, caseSensitive: boolean): readonly string[];
|
|
20
22
|
export type CasingOptions = {
|