[Pkg-javascript-commits] [node-jsonstream] 35/214: factored out key checks into check() and added a boolean case, now passes bool test

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 1 12:58:35 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-jsonstream.

commit f09a1345f16725b958dabec86349a0c069bae88d
Author: James Halliday <mail at substack.net>
Date:   Thu Jun 14 03:59:42 2012 -0700

    factored out key checks into check() and added a boolean case, now passes bool test
---
 index.js | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/index.js b/index.js
index 31bf1fe..646c7d5 100644
--- a/index.js
+++ b/index.js
@@ -32,10 +32,7 @@ exports.parse = function (path) {
       if(!c) {
         return
       }
-      var m = 
-       ( 'string' === typeof key 
-          ? c.key == key
-          : key.exec(c.key)) 
+      var m = check(key, c.key)
       _path.push(c.key)
         
        if(!m)
@@ -45,10 +42,7 @@ exports.parse = function (path) {
     var c = this
  
     var key = path[path.length - 1]
-      var m = 
-       ( 'string' === typeof key 
-          ? c.key == key
-          : key.exec(c.key)) 
+      var m = check(key, c.key)
      if(!m)
       return
       _path.push(c.key)
@@ -85,6 +79,15 @@ exports.parse = function (path) {
   return stream
 }
 
+function check (x, y) {
+  if ('string' === typeof x)
+    return y == x
+  else if (x && 'function' === typeof x.exec)
+    return x.exec(y)
+  else if ('boolean' === typeof x)
+    return x
+}
+
 exports.stringify = function (op, sep, cl) {
   if (op === false){
     op = ''

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-jsonstream.git



More information about the Pkg-javascript-commits mailing list