MCPcopy
hub / github.com/webpack/webpack / getCommonSuffix

Function getCommonSuffix

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

Source from the content-addressed store, hash-verified

196 * @returns {string} common suffix
197 */
198const getCommonSuffix = (items) => {
199 let suffix = items[0];
200 for (let i = 1; i < items.length; i++) {
201 const item = items[i];
202 for (let p = item.length - 1, s = suffix.length - 1; s >= 0; p--, s--) {
203 if (item[p] !== suffix[s]) {
204 suffix = suffix.slice(s + 1);
205 break;
206 }
207 }
208 }
209 return suffix;
210};
211
212/**
213 * Returns regexp.

Callers 1

itemsToRegexpFunction · 0.85

Calls 1

sliceMethod · 0.80

Tested by

no test coverage detected