Socket
Socket
Sign inDemoInstall

jsonsql

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.2 to 0.0.3

14

examples/query.js

@@ -202,3 +202,15 @@ var dataSource = {

function __iterate(obj) {
for (var k in obj) {
if (obj.hasOwnProperty(k)) {
if (!Array.isArray(obj[k]) && typeof obj[k] === 'object') {
__iterate(obj[k]);
} else {
console.log(k, ':', obj[k]);
}
}
}
}
var Query = require('../index');

@@ -208,3 +220,3 @@ var res = Query(dataSource, '* where holy.name=CRAP || (holy.name=CREEPY && (state=1 || state=2))');

var res = Query(dataSource, '*.id where holy.name=CRAP');
var res = Query(dataSource, '*.id, *.holy.addr where holy.name=CRAP');
console.log('======RESULT 2\n',res);

42

index.js

@@ -11,2 +11,3 @@ var AND = '&&'

, WILDCARD = '*'
, COMMA = ','
, DELIMITER = '.'

@@ -28,5 +29,10 @@ , LEFT = '('

synopsis.pathway = __splitTrim(pathway, DELIMITER);
if (synopsis.pathway[0] == WILDCARD)
synopsis.pathway.shift();
synopsis.pathway = __splitTrim(pathway, COMMA);
for (var i = 0, len = synopsis.pathway.length; i < len; i++) {
synopsis.pathway[i] = __splitTrim(synopsis.pathway[i], DELIMITER);
if (synopsis.pathway[i][0] == WILDCARD)
synopsis.pathway[i].shift();
if(synopsis.pathway[i].length === 0)
synopsis.pathway.splice(i, 1);
}

@@ -148,13 +154,3 @@ var lastLeft = -1,

}
function __iterate(obj) {
for (var k in obj) {
if (obj.hasOwnProperty(k)) {
if (!Array.isArray(obj[k]) && typeof obj[k] === 'object') {
__iterate(obj[k]);
} else {
console.log(k, ':', obj[k]);
}
}
}
}
function FilterOR(ASTNode, row) {

@@ -165,3 +161,3 @@ var res = false;

res = res || filterFunc(ASTNode[k], row);
if(options.trace)
if (options.trace)
console.log(synopsis.step, '======((( or', ASTNode[k], res);

@@ -177,3 +173,3 @@ if (res) return res;

res = res && filterFunc(ASTNode[k], row);
if(options.trace)
if (options.trace)
console.log(synopsis.step, '======((( and', ASTNode[k], res);

@@ -188,3 +184,3 @@ if (!res) return res;

var res = FilterOR(ASTNode.or, row);
if(options.trace)
if (options.trace)
console.log(synopsis.step, 'OR', ASTNode, res);

@@ -194,3 +190,3 @@ return res;

var res = FilterAND(ASTNode.and, row);
if(options.trace)
if (options.trace)
console.log(synopsis.step, 'AND', ASTNode, res);

@@ -221,4 +217,10 @@ return res;

if (result && synopsis.pathway.length > 0) {
//console.log(synopsis.pathway);
return result.map(function (ele) {
return __hierarchize(ele, synopsis.pathway.join('.'));
var res = {};
for(var i = 0, len = synopsis.pathway.length; i< len; i++){
var key = synopsis.pathway[i].join(DELIMITER);
res[key] = __hierarchize(ele, key);
}
return res;
});

@@ -236,3 +238,3 @@ }

opts = opts || {
trace :false
trace: false
};

@@ -239,0 +241,0 @@ options = opts;

{
"name": "jsonsql",
"version": "0.0.2",
"version": "0.0.3",
"description" : "A SQL-like query language for JSON objects.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc