MCPcopy
hub / github.com/webpack/webpack / formatRange

Function formatRange

lib/util/compileBooleanMatcher.js:73–87  ·  view source on GitHub ↗
(start, end)

Source from the content-addressed store, hash-verified

71 * @returns {string} formatted range
72 */
73const formatRange = (start, end) => {
74 const startCode = start.charCodeAt(0);
75 const endCode = end.charCodeAt(0);
76 const length = endCode - startCode + 1;
77
78 if (length === 1) {
79 return quoteMetaInCharClass(start);
80 }
81 if (length === 2) {
82 // For 2 chars, just list them (e.g., "ab" instead of "a-b")
83 return quoteMetaInCharClass(start) + quoteMetaInCharClass(end);
84 }
85 // For 3+ chars, use range notation
86 return `${quoteMetaInCharClass(start)}-${quoteMetaInCharClass(end)}`;
87};
88
89/**
90 * Returns string.

Callers 1

charsToCharClassContentFunction · 0.85

Calls 1

quoteMetaInCharClassFunction · 0.85

Tested by

no test coverage detected