This repository has been archived on 2020-11-02. You can view files and clone it, but cannot push or open issues or pull requests.
TripSit_Suite/node_modules/execall/index.js

25 lines
474 B
JavaScript

'use strict';
const cloneRegexp = require('clone-regexp');
module.exports = (regexp, string) => {
let match;
const matches = [];
const clonedRegexp = cloneRegexp(regexp, {lastIndex: 0});
const isGlobal = clonedRegexp.global;
// eslint-disable-next-line no-cond-assign
while (match = clonedRegexp.exec(string)) {
matches.push({
match: match[0],
subMatches: match.slice(1),
index: match.index
});
if (!isGlobal) {
break;
}
}
return matches;
};