summaryrefslogtreecommitdiff
path: root/alarm/node_modules/string-collapse-leading-whitespace/dist/string-collapse-leading-whitespace.esm.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-10-18 08:59:09 +0200
committerMinteck <contact@minteck.org>2022-10-18 08:59:09 +0200
commit2c4ae43e688a9873e86211ea0e7aeb9ba770dd77 (patch)
tree17848d95522dab25d3cdeb9c4a6450e2a234861f /alarm/node_modules/string-collapse-leading-whitespace/dist/string-collapse-leading-whitespace.esm.js
parent108525534c28013cfe1897c30e4565f9893f3766 (diff)
downloadpluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.tar.gz
pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.tar.bz2
pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.zip
Update
Diffstat (limited to 'alarm/node_modules/string-collapse-leading-whitespace/dist/string-collapse-leading-whitespace.esm.js')
-rw-r--r--alarm/node_modules/string-collapse-leading-whitespace/dist/string-collapse-leading-whitespace.esm.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/alarm/node_modules/string-collapse-leading-whitespace/dist/string-collapse-leading-whitespace.esm.js b/alarm/node_modules/string-collapse-leading-whitespace/dist/string-collapse-leading-whitespace.esm.js
new file mode 100644
index 0000000..e1dd34f
--- /dev/null
+++ b/alarm/node_modules/string-collapse-leading-whitespace/dist/string-collapse-leading-whitespace.esm.js
@@ -0,0 +1,82 @@
+/**
+ * @name string-collapse-leading-whitespace
+ * @fileoverview Collapse the leading and trailing whitespace of a string
+ * @version 5.1.0
+ * @author Roy Revelt, Codsen Ltd
+ * @license MIT
+ * {@link https://codsen.com/os/string-collapse-leading-whitespace/}
+ */
+
+var version$1 = "5.1.0";
+
+const version = version$1;
+function collWhitespace(str, originallineBreakLimit = 1) {
+ const rawNbsp = "\u00A0";
+ function reverse(s) {
+ return Array.from(s).reverse().join("");
+ }
+ function prep(whitespaceChunk, limit, trailing) {
+ const firstBreakChar = trailing ? "\n" : "\r";
+ const secondBreakChar = trailing ? "\r" : "\n";
+ if (!whitespaceChunk) {
+ return whitespaceChunk;
+ }
+ let crlfCount = 0;
+ let res = "";
+ for (let i = 0, len = whitespaceChunk.length; i < len; i++) {
+ if (whitespaceChunk[i] === firstBreakChar || whitespaceChunk[i] === secondBreakChar && whitespaceChunk[i - 1] !== firstBreakChar) {
+ crlfCount++;
+ }
+ if (`\r\n`.includes(whitespaceChunk[i]) || whitespaceChunk[i] === rawNbsp) {
+ if (whitespaceChunk[i] === rawNbsp) {
+ res += whitespaceChunk[i];
+ } else if (whitespaceChunk[i] === firstBreakChar) {
+ if (crlfCount <= limit) {
+ res += whitespaceChunk[i];
+ if (whitespaceChunk[i + 1] === secondBreakChar) {
+ res += whitespaceChunk[i + 1];
+ i++;
+ }
+ }
+ } else if (whitespaceChunk[i] === secondBreakChar && (!whitespaceChunk[i - 1] || whitespaceChunk[i - 1] !== firstBreakChar) && crlfCount <= limit) {
+ res += whitespaceChunk[i];
+ }
+ } else {
+ if (!whitespaceChunk[i + 1] && !crlfCount) {
+ res += " ";
+ }
+ }
+ }
+ return res;
+ }
+ if (typeof str === "string" && str.length) {
+ let lineBreakLimit = 1;
+ if (typeof +originallineBreakLimit === "number" && Number.isInteger(+originallineBreakLimit) && +originallineBreakLimit >= 0) {
+ lineBreakLimit = +originallineBreakLimit;
+ }
+ let frontPart = "";
+ let endPart = "";
+ if (!str.trim()) {
+ frontPart = str;
+ } else if (!str[0].trim()) {
+ for (let i = 0, len = str.length; i < len; i++) {
+ if (str[i].trim()) {
+ frontPart = str.slice(0, i);
+ break;
+ }
+ }
+ }
+ if (str.trim() && (str.slice(-1).trim() === "" || str.slice(-1) === rawNbsp)) {
+ for (let i = str.length; i--;) {
+ if (str[i].trim()) {
+ endPart = str.slice(i + 1);
+ break;
+ }
+ }
+ }
+ return `${prep(frontPart, lineBreakLimit, false)}${str.trim()}${reverse(prep(reverse(endPart), lineBreakLimit, true))}`;
+ }
+ return str;
+}
+
+export { collWhitespace, version };