Comparing version 1.0.2 to 1.0.3
@@ -57,9 +57,8 @@ var util = require('./util') | ||
function parse (tokens) { | ||
return _buildTree(tokens, {}, []) | ||
return _buildTree(tokens, {}) | ||
} | ||
function _buildTree (tokens, parent, stack) { | ||
function _buildTree (tokens, parent) { | ||
var props = {} | ||
var token | ||
var peek | ||
@@ -69,7 +68,4 @@ while ((token = tokens.shift())) { | ||
token.type = 'object' | ||
token.properties = _buildTree(tokens, token, stack) | ||
// exit if in object stack | ||
peek = stack[stack.length - 1] | ||
if (peek && (peek.tag === '/')) { | ||
stack.pop() | ||
token.properties = _buildTree(tokens, token) | ||
if (parent.hasChild) { | ||
_addToken(token, props) | ||
@@ -81,10 +77,8 @@ return props | ||
} else if (token.tag === '(') { | ||
stack.push(token) | ||
parent.type = 'array' | ||
continue | ||
} else if (token.tag === ')') { | ||
stack.pop(token) | ||
return props | ||
} else if (token.tag === '/') { | ||
stack.push(token) | ||
parent.hasChild = true | ||
continue | ||
@@ -91,0 +85,0 @@ } |
{ | ||
"name": "json-mask", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Tiny language and engine for selecting specific parts of a JS object, hiding the rest.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
@@ -48,2 +48,70 @@ /* global describe, it */ | ||
c: { type: 'object' } | ||
}, | ||
'a(b/c,e)': { | ||
a: { | ||
type: 'array', | ||
properties: { | ||
b: { | ||
type: 'object', | ||
properties: { | ||
c: { type: 'object' } | ||
} | ||
}, | ||
e: { type: 'object' } | ||
} | ||
} | ||
}, | ||
'a(b/c),e': { | ||
a: { | ||
type: 'array', | ||
properties: { | ||
b: { | ||
type: 'object', | ||
properties: { | ||
c: { type: 'object' } | ||
} | ||
} | ||
} | ||
}, | ||
e: { type: 'object' } | ||
}, | ||
'a(b/c/d),e': { | ||
a: { | ||
type: 'array', | ||
properties: { | ||
b: { | ||
type: 'object', | ||
properties: { | ||
c: { | ||
type: 'object', | ||
properties: { | ||
d: { type: 'object' } | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
e: { type: 'object' } | ||
}, | ||
'a(b/g(c)),e': { | ||
a: { | ||
type: 'array', | ||
properties: { | ||
b: { | ||
type: 'object', | ||
properties: { | ||
g: { | ||
type: 'array', | ||
properties: { | ||
c: { | ||
type: 'object' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
e: { type: 'object' } | ||
} | ||
@@ -50,0 +118,0 @@ } |
@@ -151,2 +151,21 @@ /* global describe, it */ | ||
e: { a: { b: 4 } } | ||
}, { | ||
m: 'a(b/c),e', | ||
o: { a: [{ b: { c: 1 } }, { d: 2 }], e: 3, f: 4, g: 5 }, | ||
e: { a: [{ b: { c: 1 } }, {}], e: 3 } | ||
}, { | ||
m: 'a(b/c/d),e', | ||
o: { a: [{ b: { c: { d: 1 } } }, { d: 2 }], e: 3, f: 4, g: 5 }, | ||
e: { a: [{ b: { c: { d: 1 } } }, {}], e: 3 } | ||
}, { | ||
m: 'beta(first,second/third),cappa(first,second/third)', | ||
o: { | ||
alpha: 3, | ||
beta: { first: 'fv', second: { third: 'tv', fourth: 'fv' } }, | ||
cappa: { first: 'fv', second: { third: 'tv', fourth: 'fv' } } | ||
}, | ||
e: { | ||
beta: { first: 'fv', second: { third: 'tv' } }, | ||
cappa: { first: 'fv', second: { third: 'tv' } } | ||
} | ||
}] | ||
@@ -157,2 +176,3 @@ | ||
for (i = 0; i < tests.length; i++) { | ||
// for (i = tests.length - 1; i < tests.length; i++) { | ||
(function (test) { | ||
@@ -159,0 +179,0 @@ it('should mask ' + test.m + ' in test #' + i, function () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77979
1110