queryfilters
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -9,1 +9,2 @@ # Version 1.0 | ||
- add installation in readme file | ||
- accept limited list of combinators |
{ | ||
"name": "queryfilters", | ||
"version": "v0.1.4", | ||
"version": "v0.1.5", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "test": "jest" |
@@ -10,2 +10,4 @@ function QueryQl() { | ||
this.combinators = ['filtering', 'or', 'and']; | ||
this.applyFilter = function (filter) { | ||
@@ -27,10 +29,15 @@ this.filters.push(filter); | ||
this.getQueryString = function (combinator = null) { | ||
this.setCombinator = function (combinator) { | ||
this.combine = combinator; | ||
return this; | ||
}; | ||
this.getQueryString = function () { | ||
if (!this.combinators.includes(this.combine)) { | ||
throw new Error('combinator ' + this.combine + ' is not available'); | ||
} | ||
var qs = ''; | ||
var rel = ''; | ||
if (combinator) { | ||
this.combine = combinator; | ||
} | ||
for (f in this.filters) { | ||
@@ -37,0 +44,0 @@ var filter = this.filters[f]; |
@@ -56,3 +56,3 @@ const QueryQl = require('./queryql'); | ||
for (i in operators) { | ||
expect(queryQl.getQueryString(operators[i])).toEqual( | ||
expect(queryQl.setCombinator(operators[i]).getQueryString()).toEqual( | ||
'rel=relation,foo,bar' | ||
@@ -64,1 +64,14 @@ + '&' + operators[i] + '[_embedded.relation.nick]=@sensorario' | ||
}); | ||
test('accept limited list of combinator', () => { | ||
var queryQl = new QueryQl() | ||
var catched = false; | ||
try { | ||
queryQl.setCombinator('invalid').getQueryString() | ||
} catch (e) { | ||
catched = true; | ||
} | ||
expect(catched).toEqual(true); | ||
}); |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
7552
132