Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

also allow skipping at onopenobject

  • Loading branch information...
commit 4b452308cf1b94a1348a42789c1551a3ecbcebe7 1 parent 5e32678
@thejh thejh authored
Showing with 18 additions and 13 deletions.
  1. +5 −5 clarinet.js
  2. +13 −8 samples/npm_getnano.js
View
10 clarinet.js
@@ -336,13 +336,13 @@ if(typeof FastList === 'function') {
if(c===':') {
if(parser.state === S.CLOSE_OBJECT) {
parser.stack.push(S.CLOSE_OBJECT);
- closeValue(parser, 'onopenobject');
+ var wantSkip = closeValue(parser, 'onopenobject');
} else {
var wantSkip = closeValue(parser, 'onkey');
- if (wantSkip) {
- parser.state = S.IGNORE;
- continue;
- }
+ }
+ if (wantSkip) {
+ parser.state = S.IGNORE;
+ continue;
}
parser.state = S.VALUE;
} else if (c==='}') {
View
21 samples/npm_getnano.js
@@ -9,8 +9,20 @@ var print = true;
parser.onopenobject = function(name) {
depth++;
if (print) console.log('OPEN WITH KEY: '+name);
+ return handleKey(name);
};
+function handleKey(name) {
+ if (name!=='nano' && depth === 1) {
+ // IGNORE
+ return true/*!!!*/;
+ } else if (name==='nano' && depth === 1) {
+ print = true
+ }
+ //if (depth === 2) console.log(depth+' KEY: '+name);
+ return false;
+}
+
parser.oncloseobject = function() {
depth--;
if (print) {
@@ -20,15 +32,8 @@ parser.oncloseobject = function() {
};
parser.onkey = function(name) {
- if (name!=='nano' && depth === 1) {
- // IGNORE
- return true/*!!!*/;
- } else if (name==='nano' && depth === 1) {
- print = true
- }
if (print) console.log('KEY: '+name)
- //if (depth === 2) console.log(depth+' KEY: '+name);
- return false;
+ return handleKey(name)
};
parser.onvalue = function(value) {

2 comments on commit 4b45230

@dscape
Owner

Can we merge this to master?

@thejh
Collaborator

@dscape Hmm... I'm pretty sure it works fine, but there are no tests yet.

Please sign in to comment.
Something went wrong with that request. Please try again.