Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vega-selections

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-selections - npm Package Compare versions

Comparing version 5.4.1 to 5.4.2

src/util.js

16

build/vega-selection.js

@@ -147,2 +147,11 @@ (function (global, factory) {

// Registers vega-util field accessors to protect against XSS attacks
const SELECTION_GETTER = Symbol('vega_selection_getter');
function getter(f) {
if (!f.getter || !f.getter[SELECTION_GETTER]) {
f.getter = vegaUtil.field(f.field);
f.getter[SELECTION_GETTER] = true;
}
return f.getter;
}
const Intersect = 'intersect';

@@ -174,7 +183,6 @@ const Union = 'union';

f = fields[i];
f.getter = vegaUtil.field.getter || vegaUtil.field(f.field);
dval = f.getter(datum);
dval = getter(f)(datum);
if (vegaUtil.isDate(dval)) dval = vegaUtil.toNumber(dval);
if (vegaUtil.isDate(values[i])) values[i] = vegaUtil.toNumber(values[i]);
if (vegaUtil.isDate(values[i][0])) values[i] = values[i].map(vegaUtil.toNumber);
if (vegaUtil.isArray(values[i]) && vegaUtil.isDate(values[i][0])) values[i] = values[i].map(vegaUtil.toNumber);
if (f.type === TYPE_ENUM) {

@@ -287,3 +295,3 @@ // Enumerated fields can either specify individual values (single/multi selections)

return array.map(x => vegaUtil.extend(base.fields ? {
values: base.fields.map(f => (f.getter || (f.getter = vegaUtil.field(f.field)))(x.datum))
values: base.fields.map(f => getter(f)(x.datum))
} : {

@@ -290,0 +298,0 @@ [SelectionId]: $selectionId(x.datum)

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util"),require("vega-expression")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-expression"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).vega={},e.vega,e.vega)}(this,(function(e,t,n){"use strict";function r(e,t){return null==e||null==t?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function i(e,t){return null==e||null==t?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function u(){return 0}class o extends Set{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l;if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),null!=e)for(const t of e)this.add(t)}has(e){return super.has(function(e,t){let{_intern:n,_key:r}=e;const i=r(t);return n.has(i)?n.get(i):t}(this,e))}add(e){return super.add(function(e,t){let{_intern:n,_key:r}=e;const i=r(t);return n.has(i)?n.get(i):(n.set(i,t),t)}(this,e))}delete(e){return super.delete(function(e,t){let{_intern:n,_key:r}=e;const i=r(t);n.has(i)&&(t=n.get(i),n.delete(i));return t}(this,e))}}function l(e){return null!==e&&"object"==typeof e?e.valueOf():e}function f(e){return e instanceof o?e:new o(e)}const s="intersect",a="union",c="vlMulti",d="vlPoint",h="or",g="and",v="_vgsid_",p=t.field(v),y="E",m="R",_="R-E",b="R-LE",N="R-RE",x="index:unit";function O(e,n){for(var r,i,u=n.fields,o=n.values,l=u.length,f=0;f<l;++f)if((i=u[f]).getter=t.field.getter||t.field(i.field),r=i.getter(e),t.isDate(r)&&(r=t.toNumber(r)),t.isDate(o[f])&&(o[f]=t.toNumber(o[f])),t.isDate(o[f][0])&&(o[f]=o[f].map(t.toNumber)),i.type===y){if(t.isArray(o[f])?o[f].indexOf(r)<0:r!==o[f])return!1}else if(i.type===m){if(!t.inrange(r,o[f]))return!1}else if(i.type===N){if(!t.inrange(r,o[f],!0,!1))return!1}else if(i.type===_){if(!t.inrange(r,o[f],!1,!1))return!1}else if(i.type===b&&!t.inrange(r,o[f],!1,!0))return!1;return!0}const w=function(e){let t,n,o;function l(e,r){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.length;if(i<u){if(0!==t(r,r))return u;do{const t=i+u>>>1;n(e[t],r)<0?i=t+1:u=t}while(i<u)}return i}return 2!==e.length?(t=r,n=(t,n)=>r(e(t),n),o=(t,n)=>e(t)-n):(t=e===r||e===i?e:u,n=e,o=e),{left:l,center:function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const r=l(e,t,n,(arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.length)-1);return r>n&&o(e[r-1],t)>-o(e[r],t)?r-1:r},right:function(e,r){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.length;if(i<u){if(0!==t(r,r))return u;do{const t=i+u>>>1;n(e[t],r)<=0?i=t+1:u=t}while(i<u)}return i}}}(p),R=w.left,k=w.right;var j={[`${v}_union`]:function(){const e=new o;for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];for(const t of n)for(const n of t)e.add(n);return e},[`${v}_intersect`]:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];e=new o(e),n=n.map(f);e:for(const t of e)for(const r of n)if(!r.has(t)){e.delete(t);continue e}return e},E_union:function(e,t){if(!e.length)return t;for(var n=0,r=t.length;n<r;++n)e.indexOf(t[n])<0&&e.push(t[n]);return e},E_intersect:function(e,t){return e.length?e.filter((e=>t.indexOf(e)>=0)):t},R_union:function(e,n){var r=t.toNumber(n[0]),i=t.toNumber(n[1]);return r>i&&(r=n[1],i=n[0]),e.length?(e[0]>r&&(e[0]=r),e[1]<i&&(e[1]=i),e):[r,i]},R_intersect:function(e,n){var r=t.toNumber(n[0]),i=t.toNumber(n[1]);return r>i&&(r=n[1],i=n[0]),e.length?i<e[0]||e[1]<r?[]:(e[0]<r&&(e[0]=r),e[1]>i&&(e[1]=i),e):[r,i]}};const E=":",$="@";e.selectionIdTest=function(e,t,n){const r=this.context.data[e],i=r?r.values.value:[],u=r?r[x]&&r[x].value:void 0,o=n===s,l=p(t),f=R(i,l);if(f===i.length)return!1;if(p(i[f])!==l)return!1;if(u&&o){if(1===u.size)return!0;if(k(i,l)-f<u.size)return!1}return!0},e.selectionResolve=function(e,n,r,i){for(var u,o,l,f,s,y,m,_,b,N,x,O,w=this.context.data[e],R=w?w.values.value:[],k={},E={},$={},D=R.length,T=0;T<D;++T)if(f=(u=R[T]).unit,o=u.fields,l=u.values,o&&l){for(x=0,O=o.length;x<O;++x)s=o[x],_=(m=k[s.field]||(k[s.field]={}))[f]||(m[f]=[]),$[s.field]=b=s.type.charAt(0),N=j[`${b}_union`],m[f]=N(_,t.array(l[x]));r&&(_=E[f]||(E[f]=[])).push(t.array(l).reduce(((e,t,n)=>(e[o[n].field]=t,e)),{}))}else s=v,y=p(u),(_=(m=k[s]||(k[s]={}))[f]||(m[f]=[])).push(y),r&&(_=E[f]||(E[f]=[])).push({[v]:y});if(n=n||a,k[v]?k[v]=j[`${v}_${n}`](...Object.values(k[v])):Object.keys(k).forEach((e=>{k[e]=Object.keys(k[e]).map((t=>k[e][t])).reduce(((t,r)=>void 0===t?r:j[`${$[e]}_${n}`](t,r)))})),R=Object.keys(E),r&&R.length){k[i?d:c]=n===a?{[h]:R.reduce(((e,t)=>(e.push(...E[t]),e)),[])}:{[g]:R.map((e=>({[h]:E[e]})))}}return k},e.selectionTest=function(e,t,n){for(var r,i,u,o,l,f=this.context.data[e],a=f?f.values.value:[],c=f?f[x]&&f[x].value:void 0,d=n===s,h=a.length,g=0;g<h;++g)if(r=a[g],c&&d){if(-1===(u=(i=i||{})[o=r.unit]||0))continue;if(l=O(t,r),i[o]=l?-1:++u,l&&1===c.size)return!0;if(!l&&u===c.get(o).count)return!1}else if(d^(l=O(t,r)))return l;return h&&d},e.selectionTuples=function(e,n){return e.map((e=>t.extend(n.fields?{values:n.fields.map((n=>(n.getter||(n.getter=t.field(n.field)))(e.datum)))}:{[v]:p(e.datum)},n)))},e.selectionVisitor=function(e,r,i,u){r[0].type!==n.Literal&&t.error("First argument to selection functions must be a string literal.");const o=r[0].value,l=r.length>=2&&t.peek(r).value,f="unit",a=$+f,c=E+o;l!==s||t.hasOwnProperty(u,a)||(u[a]=i.getData(o).indataRef(i,f)),t.hasOwnProperty(u,c)||(u[c]=i.getData(o).tuplesRef())}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util"),require("vega-expression")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-expression"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).vega={},e.vega,e.vega)}(this,(function(e,t,n){"use strict";function r(e,t){return null==e||null==t?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function i(e,t){return null==e||null==t?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function u(){return 0}class o extends Set{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l;if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),null!=e)for(const t of e)this.add(t)}has(e){return super.has(function(e,t){let{_intern:n,_key:r}=e;const i=r(t);return n.has(i)?n.get(i):t}(this,e))}add(e){return super.add(function(e,t){let{_intern:n,_key:r}=e;const i=r(t);return n.has(i)?n.get(i):(n.set(i,t),t)}(this,e))}delete(e){return super.delete(function(e,t){let{_intern:n,_key:r}=e;const i=r(t);n.has(i)&&(t=n.get(i),n.delete(i));return t}(this,e))}}function l(e){return null!==e&&"object"==typeof e?e.valueOf():e}function s(e){return e instanceof o?e:new o(e)}const f=Symbol("vega_selection_getter");function a(e){return e.getter&&e.getter[f]||(e.getter=t.field(e.field),e.getter[f]=!0),e.getter}const c="intersect",d="union",g="_vgsid_",h=t.field(g),v="E",p="R",y="R-E",_="R-LE",m="R-RE",b="index:unit";function N(e,n){for(var r,i,u=n.fields,o=n.values,l=u.length,s=0;s<l;++s)if(r=a(i=u[s])(e),t.isDate(r)&&(r=t.toNumber(r)),t.isDate(o[s])&&(o[s]=t.toNumber(o[s])),t.isArray(o[s])&&t.isDate(o[s][0])&&(o[s]=o[s].map(t.toNumber)),i.type===v){if(t.isArray(o[s])?o[s].indexOf(r)<0:r!==o[s])return!1}else if(i.type===p){if(!t.inrange(r,o[s]))return!1}else if(i.type===m){if(!t.inrange(r,o[s],!0,!1))return!1}else if(i.type===y){if(!t.inrange(r,o[s],!1,!1))return!1}else if(i.type===_&&!t.inrange(r,o[s],!1,!0))return!1;return!0}const x=function(e){let t,n,o;function l(e,r){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.length;if(i<u){if(0!==t(r,r))return u;do{const t=i+u>>>1;n(e[t],r)<0?i=t+1:u=t}while(i<u)}return i}return 2!==e.length?(t=r,n=(t,n)=>r(e(t),n),o=(t,n)=>e(t)-n):(t=e===r||e===i?e:u,n=e,o=e),{left:l,center:function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const r=l(e,t,n,(arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.length)-1);return r>n&&o(e[r-1],t)>-o(e[r],t)?r-1:r},right:function(e,r){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.length;if(i<u){if(0!==t(r,r))return u;do{const t=i+u>>>1;n(e[t],r)<=0?i=t+1:u=t}while(i<u)}return i}}}(h),O=x.left,w=x.right;var R={[`${g}_union`]:function(){const e=new o;for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];for(const t of n)for(const n of t)e.add(n);return e},[`${g}_intersect`]:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];e=new o(e),n=n.map(s);e:for(const t of e)for(const r of n)if(!r.has(t)){e.delete(t);continue e}return e},E_union:function(e,t){if(!e.length)return t;for(var n=0,r=t.length;n<r;++n)e.indexOf(t[n])<0&&e.push(t[n]);return e},E_intersect:function(e,t){return e.length?e.filter((e=>t.indexOf(e)>=0)):t},R_union:function(e,n){var r=t.toNumber(n[0]),i=t.toNumber(n[1]);return r>i&&(r=n[1],i=n[0]),e.length?(e[0]>r&&(e[0]=r),e[1]<i&&(e[1]=i),e):[r,i]},R_intersect:function(e,n){var r=t.toNumber(n[0]),i=t.toNumber(n[1]);return r>i&&(r=n[1],i=n[0]),e.length?i<e[0]||e[1]<r?[]:(e[0]<r&&(e[0]=r),e[1]>i&&(e[1]=i),e):[r,i]}};e.selectionIdTest=function(e,t,n){const r=this.context.data[e],i=r?r.values.value:[],u=r?r[b]&&r[b].value:void 0,o=n===c,l=h(t),s=O(i,l);if(s===i.length)return!1;if(h(i[s])!==l)return!1;if(u&&o){if(1===u.size)return!0;if(w(i,l)-s<u.size)return!1}return!0},e.selectionResolve=function(e,n,r,i){for(var u,o,l,s,f,a,c,v,p,y,_,m,b=this.context.data[e],N=b?b.values.value:[],x={},O={},w={},k=N.length,j=0;j<k;++j)if(s=(u=N[j]).unit,o=u.fields,l=u.values,o&&l){for(_=0,m=o.length;_<m;++_)f=o[_],v=(c=x[f.field]||(x[f.field]={}))[s]||(c[s]=[]),w[f.field]=p=f.type.charAt(0),y=R[`${p}_union`],c[s]=y(v,t.array(l[_]));r&&(v=O[s]||(O[s]=[])).push(t.array(l).reduce(((e,t,n)=>(e[o[n].field]=t,e)),{}))}else f=g,a=h(u),(v=(c=x[f]||(x[f]={}))[s]||(c[s]=[])).push(a),r&&(v=O[s]||(O[s]=[])).push({[g]:a});if(n=n||d,x[g]?x[g]=R[`${g}_${n}`](...Object.values(x[g])):Object.keys(x).forEach((e=>{x[e]=Object.keys(x[e]).map((t=>x[e][t])).reduce(((t,r)=>void 0===t?r:R[`${w[e]}_${n}`](t,r)))})),N=Object.keys(O),r&&N.length){x[i?"vlPoint":"vlMulti"]=n===d?{or:N.reduce(((e,t)=>(e.push(...O[t]),e)),[])}:{and:N.map((e=>({or:O[e]})))}}return x},e.selectionTest=function(e,t,n){for(var r,i,u,o,l,s=this.context.data[e],f=s?s.values.value:[],a=s?s[b]&&s[b].value:void 0,d=n===c,g=f.length,h=0;h<g;++h)if(r=f[h],a&&d){if(-1===(u=(i=i||{})[o=r.unit]||0))continue;if(l=N(t,r),i[o]=l?-1:++u,l&&1===a.size)return!0;if(!l&&u===a.get(o).count)return!1}else if(d^(l=N(t,r)))return l;return g&&d},e.selectionTuples=function(e,n){return e.map((e=>t.extend(n.fields?{values:n.fields.map((t=>a(t)(e.datum)))}:{[g]:h(e.datum)},n)))},e.selectionVisitor=function(e,r,i,u){r[0].type!==n.Literal&&t.error("First argument to selection functions must be a string literal.");const o=r[0].value,l="unit",s="@"+l,f=":"+o;(r.length>=2&&t.peek(r).value)!==c||t.hasOwnProperty(u,s)||(u[s]=i.getData(o).indataRef(i,l)),t.hasOwnProperty(u,f)||(u[f]=i.getData(o).tuplesRef())}}));
//# sourceMappingURL=vega-selection.min.js.map

@@ -5,2 +5,11 @@ import { bisector, union, intersection } from 'd3-array';

// Registers vega-util field accessors to protect against XSS attacks
const SELECTION_GETTER = Symbol('vega_selection_getter');
function getter(f) {
if (!f.getter || !f.getter[SELECTION_GETTER]) {
f.getter = field(f.field);
f.getter[SELECTION_GETTER] = true;
}
return f.getter;
}
const Intersect = 'intersect';

@@ -32,7 +41,6 @@ const Union = 'union';

f = fields[i];
f.getter = field.getter || field(f.field);
dval = f.getter(datum);
dval = getter(f)(datum);
if (isDate(dval)) dval = toNumber(dval);
if (isDate(values[i])) values[i] = toNumber(values[i]);
if (isDate(values[i][0])) values[i] = values[i].map(toNumber);
if (isArray(values[i]) && isDate(values[i][0])) values[i] = values[i].map(toNumber);
if (f.type === TYPE_ENUM) {

@@ -145,3 +153,3 @@ // Enumerated fields can either specify individual values (single/multi selections)

return array.map(x => extend(base.fields ? {
values: base.fields.map(f => (f.getter || (f.getter = field(f.field)))(x.datum))
values: base.fields.map(f => getter(f)(x.datum))
} : {

@@ -148,0 +156,0 @@ [SelectionId]: $selectionId(x.datum)

{
"name": "vega-selections",
"version": "5.4.1",
"version": "5.4.2",
"description": "Vega expression functions for Vega-Lite selections.",

@@ -24,7 +24,7 @@ "keywords": [

"dependencies": {
"d3-array": "3.2.2",
"d3-array": "3.2.4",
"vega-expression": "^5.0.1",
"vega-util": "^1.17.1"
},
"gitHead": "fb1092f6b931d450f9c210b67ae4752bd3dd461b"
"gitHead": "3580b28ec9b89d0a042707c168080931e7745fb3"
}
import {intersection, union} from 'd3-array';
import {array, toNumber} from 'vega-util';
import {$selectionId, And, Or, SelectionId, Union, VlMulti, VlPoint} from './constants';
import {$selectionId, And, Or, SelectionId, Union, VlMulti, VlPoint} from './util';

@@ -5,0 +5,0 @@ /**

import {bisector} from 'd3-array';
import {$selectionId, Intersect} from './constants';
import {field, inrange, isArray, isDate, toNumber} from 'vega-util';
import {inrange, isArray, isDate, toNumber} from 'vega-util';
import {$selectionId, Intersect, getter} from './util';

@@ -21,8 +21,7 @@ const TYPE_ENUM = 'E',

f = fields[i];
f.getter = field.getter || field(f.field);
dval = f.getter(datum);
dval = getter(f)(datum);
if (isDate(dval)) dval = toNumber(dval);
if (isDate(values[i])) values[i] = toNumber(values[i]);
if (isDate(values[i][0])) values[i] = values[i].map(toNumber);
if (isArray(values[i]) && isDate(values[i][0])) values[i] = values[i].map(toNumber);

@@ -29,0 +28,0 @@ if (f.type === TYPE_ENUM) {

@@ -1,3 +0,3 @@

import {extend, field} from 'vega-util';
import {$selectionId, SelectionId} from './constants';
import {extend} from 'vega-util';
import {$selectionId, SelectionId, getter} from './util';

@@ -14,3 +14,3 @@ /**

base.fields ? {
values: base.fields.map(f => (f.getter || (f.getter = field(f.field)))(x.datum))
values: base.fields.map(f => getter(f)(x.datum))
} : {

@@ -17,0 +17,0 @@ [SelectionId]: $selectionId(x.datum)

@@ -1,4 +0,4 @@

import {Intersect} from './constants';
import {Literal} from 'vega-expression';
import {error, hasOwnProperty, peek} from 'vega-util';
import {Intersect} from './util';

@@ -5,0 +5,0 @@ const DataPrefix = ':',

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