New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

queryfilters

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

queryfilters - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

2

package.json
{
"name": "queryfilters",
"version": "v0.1.5",
"version": "v0.1.6",
"scripts": {

@@ -5,0 +5,0 @@ "test": "jest"

@@ -1,38 +0,54 @@

function QueryQl() {
const relation = 1;
function Combinators () {
const COMBINATORS_AND = 'and';
const COMBINATORS_DEFAULT = 'filtering';
const COMBINATORS_OR = 'or';
this.getCombinators = function () {
return [
COMBINATORS_AND,
COMBINATORS_DEFAULT,
COMBINATORS_OR
];
}
this.getDefaultCombinator = function () {
return COMBINATORS_DEFAULT;
};
}
function QueryStringBuilder () {
this.filters = [];
this.combine = 'filtering';
var combinators = new Combinators();
this.rel = [];
this.combinators = combinators.getCombinators();
this.combinators = ['filtering', 'or', 'and'];
this.combine = combinators.getDefaultCombinator();
this.applyFilter = function (filter) {
this.filters.push(filter);
};
this.getRels = function () {
this.rel = [];
for (f in this.filters) {
var filter = this.filters[f];
if (this.containsRelations(filter)) {
filterRelation = filter.field.split('.')[relation];
this.rel.push(filterRelation);
}
this.ensureHaveValidCombinator = function ()
{
if (!this.combinators.includes(this.getCombinator())) {
throw new Error('combinator ' + this.getCombinator() + ' is not available');
}
return this.rel;
};
return this;
}
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');
}
this.getCombinator = function () {
return this.combine;
};
this.setFilters = function (filters) {
this.filters = filters;
return this;
};
this.build = function () {
var qs = '';

@@ -73,2 +89,44 @@ var rel = '';

this.containsRelations = function (filter) {
return filter.field.indexOf('_embedded') !== -1;
};
}
function QueryQl() {
const relation = 1;
this.setCombinator = function (combinator) {
this.builder.setCombinator(combinator);
return this;
};
this.builder = new QueryStringBuilder();
this.filters = [];
this.rel = [];
this.applyFilter = function (filter) {
this.filters.push(filter);
};
this.getRels = function () {
this.rel = [];
for (f in this.filters) {
var filter = this.filters[f];
if (this.builder.containsRelations(filter)) {
filterRelation = filter.field.split('.')[relation];
this.rel.push(filterRelation);
}
}
return this.rel;
};
this.getQueryString = function () {
return this.builder
.ensureHaveValidCombinator()
.setFilters(this.filters)
.build();
};
this.getFilters = function () {

@@ -81,6 +139,2 @@ var filters = [];

};
this.containsRelations = function (filter) {
return filter.field.indexOf('_embedded') !== -1;
};
}

@@ -87,0 +141,0 @@

@@ -11,4 +11,4 @@ const QueryQl = require('./queryql');

var queryQl = new QueryQl()
expect(queryQl.containsRelations({ field: 'id', value: 42 })).toBe(false);
expect(queryQl.containsRelations({ field: '_embedded.foo.bar', value: 42 })).toBe(true);
expect(queryQl.builder.containsRelations({ field: 'id', value: 42 })).toBe(false);
expect(queryQl.builder.containsRelations({ field: '_embedded.foo.bar', value: 42 })).toBe(true);
});

@@ -15,0 +15,0 @@

# queryfilters
npm install queryfilters
⇓ npm install queryfilters

@@ -5,0 +5,0 @@ ## Examples

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc