break-styled-lines
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -20,3 +20,3 @@ function isArray(text) { | ||
}, { indexToInsertInto: 0, localPosition: 0, lengthOfPreceding: 0 }); | ||
return arrayOfStrings | ||
return (arrayOfStrings | ||
.map((string, i) => { | ||
@@ -28,14 +28,18 @@ if (i === indexToInsertInto) { | ||
}) | ||
// This is to remove whitespace adjacent to newlines, but to preserve starting or trailing whitespace | ||
.map(string => string | ||
.split("\n") | ||
.map((str, i, strs) => { | ||
if (i === 0 && strs.length > 1) { | ||
if (i < strs.length - 2 && i > 0) { | ||
return str.trim(); | ||
} | ||
if (i < strs.length - 2) { | ||
return str.trimRight(); | ||
} | ||
else if (i === strs.length - 1) { | ||
else if (i > 0) { | ||
return str.trimLeft(); | ||
} | ||
return str.trim(); | ||
return str; | ||
}) | ||
.join("\n")); | ||
.join("\n"))); | ||
} | ||
@@ -42,0 +46,0 @@ function breakLines(text, width, font) { |
@@ -20,3 +20,3 @@ function isArray(text) { | ||
}, { indexToInsertInto: 0, localPosition: 0, lengthOfPreceding: 0 }); | ||
return arrayOfStrings | ||
return (arrayOfStrings | ||
.map((string, i) => { | ||
@@ -28,14 +28,18 @@ if (i === indexToInsertInto) { | ||
}) | ||
// This is to remove whitespace adjacent to newlines, but to preserve starting or trailing whitespace | ||
.map(string => string | ||
.split("\n") | ||
.map((str, i, strs) => { | ||
if (i === 0 && strs.length > 1) { | ||
if (i < strs.length - 2 && i > 0) { | ||
return str.trim(); | ||
} | ||
if (i < strs.length - 2) { | ||
return str.trimRight(); | ||
} | ||
else if (i === strs.length - 1) { | ||
else if (i > 0) { | ||
return str.trimLeft(); | ||
} | ||
return str.trim(); | ||
return str; | ||
}) | ||
.join("\n")); | ||
.join("\n"))); | ||
} | ||
@@ -42,0 +46,0 @@ function breakLines(text, width, font) { |
{ | ||
"name": "break-styled-lines", | ||
"description": "Add newlines to a string of text given a font style and width", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
19277
218
0