MCPcopy
hub / github.com/webpack/webpack / quoteMetaInCharClass

Function quoteMetaInCharClass

lib/util/compileBooleanMatcher.js:20–26  ·  view source on GitHub ↗
(char)

Source from the content-addressed store, hash-verified

18 * @returns {string} escaped character
19 */
20const quoteMetaInCharClass = (char) => {
21 // In character class, only these need escaping: ] \ ^ -
22 if (char === "]" || char === "\\" || char === "^" || char === "-") {
23 return `\\${char}`;
24 }
25 return char;
26};
27
28/**
29 * Converts an array of single characters into an optimized character class string

Callers 2

charsToCharClassContentFunction · 0.85
formatRangeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected