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

pivotql-compiler-mapboxgl

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pivotql-compiler-mapboxgl - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

51

lib/cjs/index.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,3 +6,3 @@ Object.defineProperty(exports, "__esModule", {

});
exports["default"] = void 0;
exports["default"] = exports.compile = void 0;

@@ -36,15 +36,15 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

if (node.alone) {
return ['has', _identity(node)];
return ["has", _identity(node)];
}
return ['get', _identity(node)];
return ["get", _identity(node)];
},
'-': function _(node) {
"-": function _(node) {
return -_firstChild(node).value;
},
'&&': function _(node) {
return ['all'].concat(_toConsumableArray(node.children.map(_processNode)));
"&&": function _(node) {
return ["all"].concat(_toConsumableArray(node.children.map(_processNode)));
},
'||': function _(node) {
return ['any'].concat(_toConsumableArray(node.children.map(_processNode)));
"||": function _(node) {
return ["any"].concat(_toConsumableArray(node.children.map(_processNode)));
},

@@ -60,15 +60,15 @@ ARRAY: function ARRAY(node) {

return ['in', field, ['literal', valueList]];
return ["in", field, ["literal", valueList]];
},
'!': function _(node) {
return ['!', _processNode(node.children[0])];
"!": function _(node) {
return ["!", _processNode(node.children[0])];
},
'==': function _(node) {
return ['=='].concat(_toConsumableArray(node.children.map(_processNode)));
"==": function _(node) {
return ["=="].concat(_toConsumableArray(node.children.map(_processNode)));
},
'!=': function _(node) {
return ['!='].concat(_toConsumableArray(node.children.map(_processNode)));
"!=": function _(node) {
return ["!="].concat(_toConsumableArray(node.children.map(_processNode)));
},
MATCH: function MATCH(node) {
var _match = ['in'];
var _match = ["in"];

@@ -79,13 +79,13 @@ _match.push(_processNode(node.children[1]), _processNode(node.children[0]));

},
'<': function _(node) {
return ['<'].concat(_toConsumableArray(node.children.map(_processNode)));
"<": function _(node) {
return ["<"].concat(_toConsumableArray(node.children.map(_processNode)));
},
'<=': function _(node) {
return ['<='].concat(_toConsumableArray(node.children.map(_processNode)));
"<=": function _(node) {
return ["<="].concat(_toConsumableArray(node.children.map(_processNode)));
},
'>': function _(node) {
return ['>'].concat(_toConsumableArray(node.children.map(_processNode)));
">": function _(node) {
return [">"].concat(_toConsumableArray(node.children.map(_processNode)));
},
'>=': function _(node) {
return ['>='].concat(_toConsumableArray(node.children.map(_processNode)));
">=": function _(node) {
return [">="].concat(_toConsumableArray(node.children.map(_processNode)));
},

@@ -111,4 +111,5 @@ EXPRESSION: function EXPRESSION(node) {

exports.compile = compile;
var _default = compile;
exports["default"] = _default;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -18,18 +18,18 @@ const _firstChild = node => {

if (node.alone) {
return ['has', _identity(node)];
return ["has", _identity(node)];
}
return ['get', _identity(node)];
return ["get", _identity(node)];
},
'-'(node) {
"-"(node) {
return -_firstChild(node).value;
},
'&&'(node) {
return ['all', ...node.children.map(_processNode)];
"&&"(node) {
return ["all", ...node.children.map(_processNode)];
},
'||'(node) {
return ['any', ...node.children.map(_processNode)];
"||"(node) {
return ["any", ...node.children.map(_processNode)];
},

@@ -47,19 +47,19 @@

return ['in', field, ['literal', valueList]];
return ["in", field, ["literal", valueList]];
},
'!'(node) {
return ['!', _processNode(node.children[0])];
"!"(node) {
return ["!", _processNode(node.children[0])];
},
'=='(node) {
return ['==', ...node.children.map(_processNode)];
"=="(node) {
return ["==", ...node.children.map(_processNode)];
},
'!='(node) {
return ['!=', ...node.children.map(_processNode)];
"!="(node) {
return ["!=", ...node.children.map(_processNode)];
},
MATCH(node) {
const _match = ['in'];
const _match = ["in"];

@@ -71,16 +71,16 @@ _match.push(_processNode(node.children[1]), _processNode(node.children[0]));

'<'(node) {
return ['<', ...node.children.map(_processNode)];
"<"(node) {
return ["<", ...node.children.map(_processNode)];
},
'<='(node) {
return ['<=', ...node.children.map(_processNode)];
"<="(node) {
return ["<=", ...node.children.map(_processNode)];
},
'>'(node) {
return ['>', ...node.children.map(_processNode)];
">"(node) {
return [">", ...node.children.map(_processNode)];
},
'>='(node) {
return ['>=', ...node.children.map(_processNode)];
">="(node) {
return [">=", ...node.children.map(_processNode)];
},

@@ -102,3 +102,3 @@

const compile = tree => {
export const compile = tree => {
const query = {};

@@ -108,4 +108,3 @@ query.filter = _processNode(tree);

};
export default compile;
//# sourceMappingURL=index.js.map
{
"name": "pivotql-compiler-mapboxgl",
"version": "0.3.0",
"version": "0.3.1",
"description": "Compile PivotQL ASTs to mapbox filter queries.",

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

@@ -15,4 +15,4 @@ # PivotQL compiler for mapbox

import parse from 'pivotql-parser-expression';
import compile from 'pivotql-compiler-mapboxgl';
import {parse} from 'pivotql-parser-expression';
import {compile} from 'pivotql-compiler-mapboxgl';

@@ -19,0 +19,0 @@ const query = '( height <= 20 or favorites.color == "green" ) and firstname in ["john", "doug"]';

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -18,15 +18,15 @@ const _firstChild = (node) => {

if (node.alone) {
return ['has', _identity(node)];
return ["has", _identity(node)];
}
return ['get', _identity(node)];
return ["get", _identity(node)];
},
'-'(node) {
"-"(node) {
return -_firstChild(node).value;
},
'&&'(node) {
return ['all', ...node.children.map(_processNode)];
"&&"(node) {
return ["all", ...node.children.map(_processNode)];
},
'||'(node) {
return ['any', ...node.children.map(_processNode)];
"||"(node) {
return ["any", ...node.children.map(_processNode)];
},

@@ -42,29 +42,29 @@ ARRAY(node) {

return ['in', field, ['literal', valueList]];
return ["in", field, ["literal", valueList]];
},
'!'(node) {
return ['!', _processNode(node.children[0])];
"!"(node) {
return ["!", _processNode(node.children[0])];
},
'=='(node) {
return ['==', ...node.children.map(_processNode)];
"=="(node) {
return ["==", ...node.children.map(_processNode)];
},
'!='(node) {
return ['!=', ...node.children.map(_processNode)];
"!="(node) {
return ["!=", ...node.children.map(_processNode)];
},
MATCH(node) {
const _match = ['in'];
const _match = ["in"];
_match.push(_processNode(node.children[1]), _processNode(node.children[0]));
return _match;
},
'<'(node) {
return ['<', ...node.children.map(_processNode)];
"<"(node) {
return ["<", ...node.children.map(_processNode)];
},
'<='(node) {
return ['<=', ...node.children.map(_processNode)];
"<="(node) {
return ["<=", ...node.children.map(_processNode)];
},
'>'(node) {
return ['>', ...node.children.map(_processNode)];
">"(node) {
return [">", ...node.children.map(_processNode)];
},
'>='(node) {
return ['>=', ...node.children.map(_processNode)];
">="(node) {
return [">=", ...node.children.map(_processNode)];
},

@@ -84,3 +84,3 @@ EXPRESSION(node) {

const compile = (tree) => {
export const compile = (tree) => {
const query = {};

@@ -87,0 +87,0 @@ query.filter = _processNode(tree);

@@ -1,16 +0,16 @@

'use strict';
"use strict";
import compiler from './index.js';
import parser from 'pivotql-parser-expression';
import compiler from "./index.js";
import parser from "pivotql-parser-expression";
describe('Basic types', () => {
test('NUMBER', () => {
expect(compiler(parser('17'))).toEqual({ filter: 17 });
describe("Basic types", () => {
test("NUMBER", () => {
expect(compiler(parser("17"))).toEqual({ filter: 17 });
});
});
describe('Basic queries', () => {
describe("Basic queries", () => {
test('foo == "bar"', () => {
expect(compiler(parser('foo == "bar"'))).toEqual({
filter: ['==', ['get', 'foo'], 'bar'],
filter: ["==", ["get", "foo"], "bar"],
});

@@ -20,18 +20,14 @@ });

expect(compiler(parser('foo != "bar"'))).toEqual({
filter: ['!=', ['get', 'foo'], 'bar'],
filter: ["!=", ["get", "foo"], "bar"],
});
});
test('foo', () => {
expect(compiler(parser('foo'))).toEqual({ filter: ['has', 'foo'] });
test("foo", () => {
expect(compiler(parser("foo"))).toEqual({ filter: ["has", "foo"] });
});
});
describe('Compound queries', () => {
describe("Compound queries", () => {
test('foo == "bar" and foo != "baz"', () => {
expect(compiler(parser('foo == "bar" and foo != "baz"'))).toEqual({
filter: [
'all',
['==', ['get', 'foo'], 'bar'],
['!=', ['get', 'foo'], 'baz'],
],
filter: ["all", ["==", ["get", "foo"], "bar"], ["!=", ["get", "foo"], "baz"]],
});

@@ -41,17 +37,11 @@ });

expect(compiler(parser('foo == "bar" or bar != 10'))).toEqual({
filter: [
'any',
['==', ['get', 'foo'], 'bar'],
['!=', ['get', 'bar'], 10],
],
filter: ["any", ["==", ["get", "foo"], "bar"], ["!=", ["get", "bar"], 10]],
});
});
test('foo == "bar" or foo != "baz" and bam == 10', () => {
expect(
compiler(parser('foo == "bar" or foo != "baz" and bam == 10'))
).toEqual({
expect(compiler(parser('foo == "bar" or foo != "baz" and bam == 10'))).toEqual({
filter: [
'any',
['==', ['get', 'foo'], 'bar'],
['all', ['!=', ['get', 'foo'], 'baz'], ['==', ['get', 'bam'], 10]],
"any",
["==", ["get", "foo"], "bar"],
["all", ["!=", ["get", "foo"], "baz"], ["==", ["get", "bam"], 10]],
],

@@ -62,15 +52,15 @@ });

expect(compiler(parser('foo in ["bar", "baz"]'))).toEqual({
filter: ['in', ['get', 'foo'], ['literal', ['bar', 'baz']]],
filter: ["in", ["get", "foo"], ["literal", ["bar", "baz"]]],
});
});
test('foo in [10, 20]', () => {
expect(compiler(parser('foo in [10, 20]'))).toEqual({
filter: ['in', ['get', 'foo'], ['literal', [10, 20]]],
test("foo in [10, 20]", () => {
expect(compiler(parser("foo in [10, 20]"))).toEqual({
filter: ["in", ["get", "foo"], ["literal", [10, 20]]],
});
});
test('foo and (bar or baz)', () => {
expect(compiler(parser('foo and (bar or baz)'))).toEqual({
filter: ['all', ['has', 'foo'], ['any', ['has', 'bar'], ['has', 'baz']]],
test("foo and (bar or baz)", () => {
expect(compiler(parser("foo and (bar or baz)"))).toEqual({
filter: ["all", ["has", "foo"], ["any", ["has", "bar"], ["has", "baz"]]],
});
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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