Comparing version 0.8.3 to 0.8.4
@@ -14,3 +14,3 @@ /* JSONPath 0.8.0 - XPath for JSON | ||
flatten: arg && arg.flatten || false, | ||
result: [], | ||
wrap: (arg && arg.hasOwnProperty('wrap')) ? arg.wrap : true, | ||
normalize: function(expr) { | ||
@@ -43,6 +43,18 @@ if(cache[expr]) { | ||
if(_.isArray(v) && P.flatten) { | ||
if(!P.result) P.result = []; | ||
P.result = P.result.concat(v); | ||
} | ||
else { | ||
P.result[P.result.length] = v; | ||
if(P.result) { | ||
if(!_.isArray(P.result)) P.result = [P.result]; | ||
if(_.isArray(v) && P.flatten) { | ||
P.result = P.result.concat(v); | ||
} | ||
else { | ||
P.result[P.result.length] = v; | ||
} | ||
} | ||
else { | ||
P.result = v; | ||
} | ||
} | ||
@@ -106,2 +118,3 @@ } | ||
}; | ||
P.result = P.wrap === true ? [] : undefined; | ||
@@ -111,4 +124,5 @@ var $ = obj; | ||
P.trace(P.normalize(expr).replace(/^\$;/,""), obj, "$"); | ||
return P.result.length ? P.result : false; | ||
if(!_.isArray(P.result) && P.wrap) P.result = [P.result]; | ||
return P.result ? P.result : false; | ||
} | ||
} |
@@ -19,3 +19,3 @@ { | ||
], | ||
"version": "0.8.3", | ||
"version": "0.8.4", | ||
"repository": { | ||
@@ -22,0 +22,0 @@ "type": "git", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
19048
11
389
1