Permalink
Browse files

all tests pass

  • Loading branch information...
1 parent 663a3f5 commit ec110c7f18c238a2b44f2d93bd5944e62d5c4fc8 @substack committed Jul 13, 2013
Showing with 9 additions and 4 deletions.
  1. +9 −4 index.js
View
@@ -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);
}
}

0 comments on commit ec110c7

Please sign in to comment.