MCPcopy
hub / github.com/webpack/webpack / getCommonPrefix

Function getCommonPrefix

lib/util/compileBooleanMatcher.js:179–191  ·  view source on GitHub ↗
(items)

Source from the content-addressed store, hash-verified

177 * @returns {string} common prefix
178 */
179const getCommonPrefix = (items) => {
180 let prefix = items[0];
181 for (let i = 1; i < items.length; i++) {
182 const item = items[i];
183 for (let p = 0; p < prefix.length; p++) {
184 if (item[p] !== prefix[p]) {
185 prefix = prefix.slice(0, p);
186 break;
187 }
188 }
189 }
190 return prefix;
191};
192
193/**
194 * Gets common suffix.

Callers 1

itemsToRegexpFunction · 0.85

Calls 1

sliceMethod · 0.80

Tested by

no test coverage detected