MCPcopy Create free account
hub / github.com/6dylan6/jdm / matchall

Method matchall

function/common.js:190–211  ·  view source on GitHub ↗
(pattern, string)

Source from the content-addressed store, hash-verified

188 return '';
189 }
190 matchall(pattern, string) {
191 pattern = (pattern instanceof Array) ? pattern : [pattern];
192 var match;
193 var result = [];
194 for (var pat of pattern) {
195 while ((match = pat.exec(string)) != null) {
196 var len = match.length;
197 if (len == 1) {
198 result.push(match);
199 } else if (len == 2) {
200 result.push(match[1]);
201 } else {
202 var r = [];
203 for (let i = 1; i < len; i++) {
204 r.push(match[i])
205 }
206 result.push(r);
207 }
208 }
209 }
210 return result;
211 }
212 compare(property) {
213 return function(a, b) {
214 var value1 = a[property];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected