@augment-vir/common
Advanced tools
Comparing version 23.1.1 to 23.2.0
@@ -41,8 +41,8 @@ "use strict"; | ||
/** Collapse all consecutive white space into just one space and trim surrounding whitespace. */ | ||
function collapseWhiteSpace(input) { | ||
return (input | ||
// sometimes \n isn't included in \s | ||
.replace(/\n/g, ' ') | ||
.trim() | ||
.replace(/\s{2,}/g, ' ')); | ||
function collapseWhiteSpace(input, { keepNewLines } = {}) { | ||
const newLineReplacement = keepNewLines | ||
? input.replace(/[\s\n]*\n+[\s\n]*/g, '\n') | ||
: // sometimes \n isn't included in \s | ||
input.replace(/\n/g, ' '); | ||
return newLineReplacement.trim().replace(/\s{2,}/g, ' '); | ||
} | ||
@@ -49,0 +49,0 @@ exports.collapseWhiteSpace = collapseWhiteSpace; |
@@ -35,8 +35,8 @@ import { ansiRegex } from './ansi'; | ||
/** Collapse all consecutive white space into just one space and trim surrounding whitespace. */ | ||
export function collapseWhiteSpace(input) { | ||
return (input | ||
// sometimes \n isn't included in \s | ||
.replace(/\n/g, ' ') | ||
.trim() | ||
.replace(/\s{2,}/g, ' ')); | ||
export function collapseWhiteSpace(input, { keepNewLines } = {}) { | ||
const newLineReplacement = keepNewLines | ||
? input.replace(/[\s\n]*\n+[\s\n]*/g, '\n') | ||
: // sometimes \n isn't included in \s | ||
input.replace(/\n/g, ' '); | ||
return newLineReplacement.trim().replace(/\s{2,}/g, ' '); | ||
} | ||
@@ -43,0 +43,0 @@ /** Same as String.prototype.split but includes the delimiter to split by in the output array. */ |
@@ -17,3 +17,5 @@ import { PartialAndUndefined } from './object/object'; | ||
/** Collapse all consecutive white space into just one space and trim surrounding whitespace. */ | ||
export declare function collapseWhiteSpace(input: string): string; | ||
export declare function collapseWhiteSpace(input: string, { keepNewLines }?: PartialAndUndefined<{ | ||
keepNewLines: boolean; | ||
}>): string; | ||
/** Same as String.prototype.split but includes the delimiter to split by in the output array. */ | ||
@@ -20,0 +22,0 @@ export declare function splitIncludeSplit(original: string, splitterInput: string | RegExp, caseSensitive: boolean): readonly string[]; |
{ | ||
"name": "@augment-vir/common", | ||
"version": "23.1.1", | ||
"version": "23.2.0", | ||
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common", | ||
@@ -5,0 +5,0 @@ "bugs": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
182986
4462