Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

all tests pass

  • Loading branch information...
commit ec110c7f18c238a2b44f2d93bd5944e62d5c4fc8 1 parent 663a3f5
@substack authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 index.js
View
13 index.js
@@ -10,16 +10,21 @@ module.exports = function pathway (root, keys) {
function check (k, v) {
if (ktype === 'boolean') {
- if (key) walk(v, index + 1);
+ if (key) next();
}
else if (ktype === 'function') {
- if (key(v, k)) walk(v, index + 1);
+ if (key(k, v)) next();
}
else if (isRegExp(key)) {
- if (key.test(k)) walk(v, index + 1);
+ if (key.test(k)) next();
}
else {
- if (key === k) walk(v, index + 1);
+ if (key === k) next();
+ }
+
+ function next () {
+ if (last) matches.push(v)
+ else walk(v, index + 1);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.