diff --git a/dist/cdn/formatters/string.js b/dist/cdn/formatters/string.js index dd2f4c5..014aced 100644 --- a/dist/cdn/formatters/string.js +++ b/dist/cdn/formatters/string.js @@ -5,9 +5,10 @@ function stringFormatter(opts = {}) { if (!quote || quote === escapedQuote) { return (value) => value; } + const quoteRegExp = new RegExp(quote, "g"); return (value) => { if (value.includes(quote)) { - value = value.replace(new RegExp(quote, "g"), escapedQuote); + value = value.replace(quoteRegExp, escapedQuote); } return `${quote}${value}${quote}`; }; diff --git a/dist/cdn/formatters/stringExcel.js b/dist/cdn/formatters/stringExcel.js index a0339cb..6eeeefb 100644 --- a/dist/cdn/formatters/stringExcel.js +++ b/dist/cdn/formatters/stringExcel.js @@ -1,8 +1,9 @@ // packages/formatters/src/stringExcel.ts var quote = '"'; var escapedQuote = '""""'; +var quoteRegExp = new RegExp(quote, "g"); function stringExcel(value) { - return `"=""${value.replace(new RegExp(quote, "g"), escapedQuote)}"""`; + return `"=""${value.replace(quoteRegExp, escapedQuote)}"""`; } export { stringExcel as default diff --git a/dist/cdn/whatwg/index.js b/dist/cdn/whatwg/index.js index f50b034..9cfa4c7 100644 --- a/dist/cdn/whatwg/index.js +++ b/dist/cdn/whatwg/index.js @@ -1,6 +1,8 @@ // packages/whatwg/src/index.ts import { default as default2 } from "./AsyncParser.js"; -import { default as default3 } from "./TransformStream.js"; +import { + default as default3 +} from "./TransformStream.js"; export { default2 as AsyncParser, default3 as TransformStream diff --git a/packages/formatters/src/string.ts b/packages/formatters/src/string.ts index c76cefd..71574d3 100644 --- a/packages/formatters/src/string.ts +++ b/packages/formatters/src/string.ts @@ -18,9 +18,10 @@ export default function stringFormatter( return (value) => value; } + const quoteRegExp = new RegExp(quote, 'g'); return (value) => { if (value.includes(quote)) { - value = value.replace(new RegExp(quote, 'g'), escapedQuote); + value = value.replace(quoteRegExp, escapedQuote); } return `${quote}${value}${quote}`; diff --git a/packages/formatters/src/stringExcel.ts b/packages/formatters/src/stringExcel.ts index 4acc82e..bb9354e 100644 --- a/packages/formatters/src/stringExcel.ts +++ b/packages/formatters/src/stringExcel.ts @@ -1,6 +1,7 @@ const quote = '"'; const escapedQuote = '""""'; +const quoteRegExp = new RegExp(quote, 'g'); export default function stringExcel(value: string) { - return `"=""${value.replace(new RegExp(quote, 'g'), escapedQuote)}"""`; + return `"=""${value.replace(quoteRegExp, escapedQuote)}"""`; } diff --git a/packages/test-helpers/utils.ts b/packages/test-helpers/utils.ts index bea194d..4be8036 100644 --- a/packages/test-helpers/utils.ts +++ b/packages/test-helpers/utils.ts @@ -1,9 +1,10 @@ +const lfRegExp = new RegExp('(?