Skip to content

Commit

Permalink
upgrade packages
Browse files Browse the repository at this point in the history
  • Loading branch information
f committed May 24, 2019
1 parent cc88293 commit c53dda0
Show file tree
Hide file tree
Showing 3 changed files with 3,084 additions and 2,012 deletions.
2 changes: 1 addition & 1 deletion dist/vue-wait.js

Large diffs are not rendered by default.

37 changes: 1 addition & 36 deletions src/lib/matcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,42 +33,7 @@ function makeRe(pattern, options) {
return re;
}

module.exports = (inputs, patterns, options) => {
if (!(Array.isArray(inputs) && Array.isArray(patterns))) {
throw new TypeError(
`Expected two arrays, got ${typeof inputs} ${typeof patterns}`
);
}

if (patterns.length === 0) {
return inputs;
}

const firstNegated = patterns[0][0] === '!';

patterns = patterns.map(x => makeRe(x, options));

const ret = [];

for (const input of inputs) {
// If first pattern is negated we include everything to match user expectation
let matches = firstNegated;

for (const pattern of patterns) {
if (pattern.test(input)) {
matches = !pattern.negated;
}
}

if (matches) {
ret.push(input);
}
}

return ret;
};

module.exports.isMatch = (input, pattern, options) => {
export const isMatch = (input, pattern, options) => {
const re = makeRe(pattern, options);
const matches = re.test(input);
return re.negated ? !matches : matches;
Expand Down
Loading

0 comments on commit c53dda0

Please sign in to comment.