MCPcopy
hub / github.com/webpack/webpack / parsePartial

Function parsePartial

lib/util/semver.js:126–149  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

124 * @returns {SemVerRangeItem[]}
125 */
126 const parsePartial = (str) => {
127 const match =
128 /** @type {RegExpExecArray} */
129 (/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(str));
130 /** @type {SemVerRangeItem[]} */
131 const ver = match[1] ? [0, ...splitAndConvert(match[1])] : [0];
132
133 if (match[2]) {
134 ver.length++;
135 ver.push.apply(ver, splitAndConvert(match[2]));
136 }
137
138 // remove trailing any matchers
139 let last = ver[ver.length - 1];
140 while (
141 ver.length &&
142 (last === undefined || /^[*xX]$/.test(/** @type {string} */ (last)))
143 ) {
144 ver.pop();
145 last = ver[ver.length - 1];
146 }
147
148 return ver;
149 };
150
151 /**
152 * Returns the sem ver range item.

Callers 2

parseSimpleFunction · 0.85
parseRangeFunction · 0.85

Calls 5

splitAndConvertFunction · 0.85
execMethod · 0.80
popMethod · 0.80
applyMethod · 0.65
testMethod · 0.45

Tested by

no test coverage detected