@nexes/nql-lang
Advanced tools
Comparing version 0.0.0 to 0.0.1
@@ -81,3 +81,3 @@ /* parser generated by jison 0.4.18 */ | ||
productions_: [0,[3,1],[4,1],[4,3],[5,1],[5,3],[7,3],[7,2],[11,1],[12,4],[12,3],[12,2],[12,1],[16,3],[16,1],[19,1],[19,1],[19,1],[19,1],[19,1],[19,1],[18,1],[18,1],[18,1],[18,1],[18,1]], | ||
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */, options) { | ||
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */, opt) { | ||
/* this == yyval */ | ||
@@ -88,3 +88,3 @@ | ||
case 1: | ||
yy.debug('expression', $$[$0]); return $$[$0]; | ||
yy.debug('expression', $$[$0]); yy.debug('opt', opt); return $$[$0]; | ||
break; | ||
@@ -97,4 +97,4 @@ case 2: | ||
yy.debug('expression OR andCondition', $$[$0-2], $$[$0]); | ||
$$[$0-2] = $$[$0-2].$or ? $$[$0-2] : {$or: [yy.deGroup($$[$0-2])]}; | ||
$$[$0-2].$or.push(yy.deGroup($$[$0])); this.$ = $$[$0-2]; | ||
$$[$0-2] = $$[$0-2].$or ? $$[$0-2] : {$or: [yy.ungroup($$[$0-2])]}; | ||
$$[$0-2].$or.push(yy.ungroup($$[$0])); this.$ = $$[$0-2]; | ||
@@ -108,4 +108,4 @@ break; | ||
yy.debug('andCondition AND filterExpr', $$[$0-2], $$[$0]); | ||
$$[$0-2] = $$[$0-2].$and ? $$[$0-2] : {$and: [yy.deGroup($$[$0-2])]}; | ||
$$[$0-2].$and.push(yy.deGroup($$[$0])); | ||
$$[$0-2] = $$[$0-2].$and ? $$[$0-2] : {$and: [yy.ungroup($$[$0-2])]}; | ||
$$[$0-2].$and.push(yy.ungroup($$[$0])); | ||
this.$ = $$[$0-2]; | ||
@@ -121,3 +121,3 @@ | ||
case 8: | ||
$$[$0] = $$[$0].replace(/:$/, ''); this.$ = $$[$0]; | ||
$$[$0] = $$[$0].replace(/:$/, ''); $$[$0] = opt.aliases && opt.aliases[$$[$0]] ? opt.aliases[$$[$0]] : $$[$0]; this.$ = $$[$0]; | ||
break; | ||
@@ -124,0 +124,0 @@ case 9: |
@@ -18,2 +18,2 @@ const parser = require('../dist/parser').parser; | ||
// returns the JSON object | ||
exports.parse = input => parser.parse(input); | ||
exports.parse = (input, options) => parser.parse(input, options || {}); |
const util = require('util'); | ||
const scope = {}; | ||
scope.deGroup = (value) => { //eslint-disable-line arrow-body-style | ||
return value.yg ? value.yg : value; | ||
}; | ||
module.exports = { | ||
ungroup(value) { | ||
return value.yg ? value.yg : value; | ||
}, | ||
scope.unescape = (value) => { | ||
var re = new RegExp('\\\\([\'"])', 'g'); | ||
return value.replace(re, '$1'); | ||
}; | ||
unescape(value) { | ||
var re = new RegExp('\\\\([\'"])', 'g'); | ||
return value.replace(re, '$1'); | ||
}, | ||
scope.debug = () => { | ||
if (!process.env.DEBUG || !/nql/.test(process.env.DEBUG)) { | ||
return; | ||
} | ||
debug() { | ||
if (!process.env.DEBUG || !/nql/.test(process.env.DEBUG)) { | ||
return; | ||
} | ||
var string = arguments[0]; | ||
var values = Array.prototype.slice.call(arguments, 1); | ||
var newArgs = [string]; | ||
var string = arguments[0]; | ||
var values = Array.prototype.slice.call(arguments, 1); | ||
var newArgs = [string]; | ||
values.forEach(function (value) { | ||
newArgs.push(util.inspect(value, false, null)); | ||
}); | ||
values.forEach(function (value) { | ||
newArgs.push(util.inspect(value, false, null)); | ||
}); | ||
console.log.apply(this, newArgs); // eslint-disable-line no-console | ||
console.log.apply(this, newArgs); // eslint-disable-line no-console | ||
} | ||
}; | ||
module.exports = scope; |
{ | ||
"name": "@nexes/nql-lang", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "tbc", | ||
@@ -14,5 +14,5 @@ "repository": "git@github.com:NexesJS/NQL-Lang.git", | ||
"posttest": "yarn lint", | ||
"test": "NODE_ENV=testing mocha -- $(find test -name '*.test.js')", | ||
"test:lex": "NODE_ENV=testing mocha -- $(find test -name 'lex*.test.js')", | ||
"test:parse": "NODE_ENV=testing mocha -- $(find test -name 'parse*.test.js')", | ||
"test": "NODE_ENV=testing mocha ./test/**/*.test.js", | ||
"test:lex": "NODE_ENV=testing mocha ./test/**/lex*.test.js", | ||
"test:parse": "NODE_ENV=testing mocha ./test/**/pars*.test.js", | ||
"preship": "yarn test", | ||
@@ -19,0 +19,0 @@ "ship": "STATUS=$(git status --porcelain); echo $STATUS; if [ -z \"$STATUS\" ]; then yarn publish && git push --follow-tags; fi" |
@@ -463,2 +463,19 @@ require('./utils'); | ||
}); | ||
describe('Aliases', function () { | ||
it('can handle empty aliases', function () { | ||
parse('tag:getting-started', {aliases: {}}) | ||
.should.eql({tag: 'getting-started'}); | ||
}); | ||
it('can expand a field alias', function () { | ||
parse('tag:getting-started', {aliases: {tag: 'tags.slug'}}) | ||
.should.eql({'tags.slug': 'getting-started'}); | ||
}); | ||
it('can expand multiple field aliases', function () { | ||
parse('tag:getting-started+author:joe', {aliases: {tag: 'tags.slug', author: 'authors.slug'}}) | ||
.should.eql({$and: [{'tags.slug': 'getting-started'}, {'authors.slug': 'joe'}]}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
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
1652
73866
19