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

vega-transforms

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-transforms - npm Package Compare versions

Comparing version 2.3.1 to 4.0.0

2

build/vega-transforms.min.js

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vega-statistics"),require("vega-dataflow"),require("vega-util"),require("d3-array")):"function"==typeof define&&define.amd?define(["exports","vega-statistics","vega-dataflow","vega-util","d3-array"],e):e((t.vega=t.vega||{},t.vega.transforms={}),t.vega,t.vega,t.vega,t.d3)}(this,function(t,m,b,E,d){"use strict";function v(t){return t&&t.length?1===t.length?t[0]:(a=t,function(t){for(var e=a.length,i=1,n=String(a[0](t));i<e;++i)n+="|"+a[i](t);return n}):function(){return""};var a}function O(t,e,i){return i||t+(e?"_"+e:"")}var l={values:i({name:"values",init:"cell.store = true;",set:"cell.data.values()",idx:-1}),count:i({name:"count",set:"cell.num"}),__count__:i({name:"count",set:"this.missing + this.valid"}),missing:i({name:"missing",set:"this.missing"}),valid:i({name:"valid",set:"this.valid"}),sum:i({name:"sum",init:"this.sum = 0;",add:"this.sum += +v;",rem:"this.sum -= v;",set:"this.sum"}),mean:i({name:"mean",init:"this.mean = 0;",add:"var d = v - this.mean; this.mean += d / this.valid;",rem:"var d = v - this.mean; this.mean -= this.valid ? d / this.valid : this.mean;",set:"this.valid ? this.mean : undefined"}),average:i({name:"average",set:"this.valid ? this.mean : undefined",req:["mean"],idx:1}),variance:i({name:"variance",init:"this.dev = 0;",add:"this.dev += d * (v - this.mean);",rem:"this.dev -= d * (v - this.mean);",set:"this.valid > 1 ? this.dev / (this.valid-1) : undefined",req:["mean"],idx:1}),variancep:i({name:"variancep",set:"this.valid > 1 ? this.dev / this.valid : undefined",req:["variance"],idx:2}),stdev:i({name:"stdev",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid-1)) : undefined",req:["variance"],idx:2}),stdevp:i({name:"stdevp",set:"this.valid > 1 ? Math.sqrt(this.dev / this.valid) : undefined",req:["variance"],idx:2}),stderr:i({name:"stderr",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid * (this.valid-1))) : undefined",req:["variance"],idx:2}),distinct:i({name:"distinct",set:"cell.data.distinct(this.get)",req:["values"],idx:3}),ci0:i({name:"ci0",set:"cell.data.ci0(this.get)",req:["values"],idx:3}),ci1:i({name:"ci1",set:"cell.data.ci1(this.get)",req:["values"],idx:3}),median:i({name:"median",set:"cell.data.q2(this.get)",req:["values"],idx:3}),q1:i({name:"q1",set:"cell.data.q1(this.get)",req:["values"],idx:3}),q3:i({name:"q3",set:"cell.data.q3(this.get)",req:["values"],idx:3}),argmin:i({name:"argmin",init:"this.argmin = undefined;",add:"if (v < this.min) this.argmin = t;",rem:"if (v <= this.min) this.argmin = undefined;",set:"this.argmin || cell.data.argmin(this.get)",req:["min"],str:["values"],idx:3}),argmax:i({name:"argmax",init:"this.argmax = undefined;",add:"if (v > this.max) this.argmax = t;",rem:"if (v >= this.max) this.argmax = undefined;",set:"this.argmax || cell.data.argmax(this.get)",req:["max"],str:["values"],idx:3}),min:i({name:"min",init:"this.min = undefined;",add:"if (v < this.min || this.min === undefined) this.min = v;",rem:"if (v <= this.min) this.min = NaN;",set:"this.min = (isNaN(this.min) ? cell.data.min(this.get) : this.min)",str:["values"],idx:4}),max:i({name:"max",init:"this.max = undefined;",add:"if (v > this.max || this.max === undefined) this.max = v;",rem:"if (v >= this.max) this.max = NaN;",set:"this.max = (isNaN(this.max) ? cell.data.max(this.get) : this.max)",str:["values"],idx:4})},e=Object.keys(l);function D(t,e){return l[t](e)}function i(i){return function(t){var e=E.extend({init:"",add:"",rem:"",idx:0},i);return e.out=t||i.name,e}}function f(t,e){return t.idx-e.idx}function k(t,e){var i=e||E.identity,n=function(t,a){var e,i=t.reduce(function e(i,t){function n(t){i[t]||e(i,i[t]=l[t]())}return t.req&&t.req.forEach(n),a&&t.str&&t.str.forEach(n),i},t.reduce(function(t,e){return t[e.name]=e,t},{})),n=[];for(e in i)n.push(i[e]);return n.sort(f)}(t,!0),a="var cell = this.cell; this.valid = 0; this.missing = 0;",r="this.cell = cell; this.init();",s="if(v==null){++this.missing; return;} if(v!==v) return; ++this.valid;",u="if(v==null){--this.missing; return;} if(v!==v) return; --this.valid;",o="var cell = this.cell;";return n.forEach(function(t){a+=t.init,s+=t.add,u+=t.rem}),t.slice().sort(f).forEach(function(t){o+="t['"+t.out+"']="+t.set+";"}),o+="return t;",(r=Function("cell",r)).prototype.init=Function(a),r.prototype.add=Function("v","t",s),r.prototype.rem=Function("v","t",u),r.prototype.set=Function("t",o),r.prototype.get=i,r.fields=t.map(function(t){return t.out}),r}function o(t){this._key=t?E.field(t):b.tupleid,this.reset()}var n=o.prototype;function a(t){b.Transform.call(this,null,t),this._adds=[],this._mods=[],this._alen=0,this._mlen=0,this._drop=!0,this._cross=!1,this._dims=[],this._dnames=[],this._measures=[],this._countOnly=!1,this._counts=null,this._prev=null,this._inputs=null,this._outputs=null}n.reset=function(){this._add=[],this._rem=[],this._ext=null,this._get=null,this._q=null},n.add=function(t){this._add.push(t)},n.rem=function(t){this._rem.push(t)},n.values=function(){if(this._get=null,0===this._rem.length)return this._add;var t,e,i,n=this._add,a=this._rem,r=this._key,s=n.length,u=a.length,o=Array(s-u),l={};for(t=0;t<u;++t)l[r(a[t])]=1;for(e=t=0;t<s;++t)l[r(i=n[t])]?l[r(i)]=0:o[e++]=i;return this._rem=[],this._add=o},n.distinct=function(t){for(var e,i=this.values(),n=i.length,a={},r=0;0<=--n;)e=t(i[n])+"",a.hasOwnProperty(e)||(a[e]=1,++r);return r},n.extent=function(t){if(this._get!==t||!this._ext){var e=this.values(),i=E.extentIndex(e,t);this._ext=[e[i[0]],e[i[1]]],this._get=t}return this._ext},n.argmin=function(t){return this.extent(t)[0]||{}},n.argmax=function(t){return this.extent(t)[1]||{}},n.min=function(t){var e=this.extent(t)[0];return null!=e?t(e):void 0},n.max=function(t){var e=this.extent(t)[1];return null!=e?t(e):void 0},n.quartile=function(t){return this._get===t&&this._q||(this._q=m.quartiles(this.values(),t),this._get=t),this._q},n.q1=function(t){return this.quartile(t)[0]},n.q2=function(t){return this.quartile(t)[1]},n.q3=function(t){return this.quartile(t)[2]},n.ci=function(t){return this._get===t&&this._ci||(this._ci=m.bootstrapCI(this.values(),1e3,.05,t),this._get=t),this._ci},n.ci0=function(t){return this.ci(t)[0]},n.ci1=function(t){return this.ci(t)[1]},a.Definition={type:"Aggregate",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:e},{name:"fields",type:"field",null:!0,array:!0},{name:"as",type:"string",null:!0,array:!0},{name:"drop",type:"boolean",default:!0},{name:"cross",type:"boolean",default:!1},{name:"key",type:"field"}]};var r=E.inherits(a,b.Transform);function s(t){b.Transform.call(this,null,t)}r.transform=function(t,e){var i,n=this,a=e.fork(e.NO_SOURCE|e.NO_FIELDS);return this.stamp=a.stamp,this.value&&((i=t.modified())||e.modified(this._inputs))?(this._prev=this.value,this.value=i?this.init(t):{},e.visit(e.SOURCE,function(t){n.add(t)})):(this.value=this.value||this.init(t),e.visit(e.REM,function(t){n.rem(t)}),e.visit(e.ADD,function(t){n.add(t)})),a.modifies(this._outputs),n._drop=!1!==t.drop,t.cross&&1<n._dims.length&&(n._drop=!1,this.cross()),n.changes(a)},r.cross=function(){var o=this,l=o.value,f=o._dnames,d=f.map(function(){return{}}),m=f.length;function t(t){var e,i,n,a;for(e in t)for(n=t[e].tuple,i=0;i<m;++i)d[i][a=n[f[i]]]=a}t(o._prev),t(l),function t(e,i,n){var a,r,s=f[n],u=d[n++];for(a in u)i[s]=u[a],r=e?e+"|"+a:a,n<m?t(r,i,n):l[r]||o.cell(r,i)}("",{},0)},r.init=function(t){var r=this._inputs=[],i=this._outputs=[],s={};function n(t){for(var e,i=E.array(E.accessorFields(t)),n=0,a=i.length;n<a;++n)s[e=i[n]]||(s[e]=1,r.push(e))}this._dims=E.array(t.groupby),this._dnames=this._dims.map(function(t){var e=E.accessorName(t);return n(t),i.push(e),e}),this.cellkey=t.key?t.key:v(this._dims),this._countOnly=!0,this._counts=[],this._measures=[];var e,a,u,o,l,f,d=t.fields||[null],m=t.ops||["count"],c=t.as||[],h=d.length,p={};for(h!==m.length&&E.error("Unmatched number of fields and aggregate ops."),f=0;f<h;++f)e=d[f],a=m[f],null==e&&"count"!==a&&E.error("Null aggregate field specified."),l=O(a,o=E.accessorName(e),c[f]),i.push(l),"count"!==a?((u=p[o])||(n(e),(u=p[o]=[]).field=e,this._measures.push(u)),"count"!==a&&(this._countOnly=!1),u.push(D(a,l))):this._counts.push(l);return this._measures=this._measures.map(function(t){return k(t,t.field)}),{}},r.cellkey=v(),r.cell=function(t,e){var i=this.value[t];return i?0===i.num&&this._drop&&i.stamp<this.stamp?(i.stamp=this.stamp,this._adds[this._alen++]=i):i.stamp<this.stamp&&(i.stamp=this.stamp,this._mods[this._mlen++]=i):(i=this.value[t]=this.newcell(t,e),this._adds[this._alen++]=i),i},r.newcell=function(t,e){var i={key:t,num:0,agg:null,tuple:this.newtuple(e,this._prev&&this._prev[t]),stamp:this.stamp,store:!1};if(!this._countOnly){var n,a=this._measures,r=a.length;for(i.agg=Array(r),n=0;n<r;++n)i.agg[n]=new a[n](i)}return i.store&&(i.data=new o),i},r.newtuple=function(t,e){var i,n,a=this._dnames,r=this._dims,s={};for(i=0,n=r.length;i<n;++i)s[a[i]]=r[i](t);return e?b.replace(e.tuple,s):b.ingest(s)},r.add=function(t){var e,i,n,a=this.cellkey(t),r=this.cell(a,t);if(r.num+=1,!this._countOnly)for(r.store&&r.data.add(t),i=0,n=(e=r.agg).length;i<n;++i)e[i].add(e[i].get(t),t)},r.rem=function(t){var e,i,n,a=this.cellkey(t),r=this.cell(a,t);if(r.num-=1,!this._countOnly)for(r.store&&r.data.rem(t),i=0,n=(e=r.agg).length;i<n;++i)e[i].rem(e[i].get(t),t)},r.celltuple=function(t){var e,i,n,a=t.tuple,r=this._counts;for(t.store&&t.data.values(),i=0,n=r.length;i<n;++i)a[r[i]]=t.num;if(!this._countOnly)for(i=0,n=(e=t.agg).length;i<n;++i)e[i].set(a);return a},r.changes=function(t){var e,i,n,a,r=this._adds,s=this._mods,u=this._prev,o=this._drop,l=t.add,f=t.rem,d=t.mod;if(u)for(i in u)e=u[i],o&&!e.num||f.push(e.tuple);for(n=0,a=this._alen;n<a;++n)l.push(this.celltuple(r[n])),r[n]=null;for(n=0,a=this._mlen;n<a;++n)(0===(e=s[n]).num&&o?f:d).push(this.celltuple(e)),s[n]=null;return this._alen=this._mlen=0,this._prev=null,t},s.Definition={type:"Bin",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"anchor",type:"number"},{name:"maxbins",type:"number",default:20},{name:"base",type:"number",default:10},{name:"divide",type:"number",array:!0,default:[5,2]},{name:"extent",type:"number",array:!0,length:2,required:!0},{name:"step",type:"number"},{name:"steps",type:"number",array:!0},{name:"minstep",type:"number",default:0},{name:"nice",type:"boolean",default:!0},{name:"name",type:"string"},{name:"as",type:"string",array:!0,length:2,default:["bin0","bin1"]}]};var u=E.inherits(s,b.Transform);function c(t,e,i){var n=t,a=e||[],r=i||[],s={},u=0;return{add:function(t){r.push(t)},remove:function(t){s[n(t)]=++u},size:function(){return a.length},data:function(t,e){return u&&(a=a.filter(function(t){return!s[n(t)]}),s={},u=0),e&&t&&a.sort(t),r.length&&(a=t?E.merge(t,a,r.sort(t)):a.concat(r),r=[]),a}}}function h(t){b.Transform.call(this,[],t)}function p(t){b.Operator.call(this,null,g,t)}function g(t){return this.value&&!t.modified()?this.value:E.compare(t.fields,t.orders)}function y(t){b.Transform.call(this,null,t)}u.transform=function(t,e){var i,n=this._bins(t),a=n.start,r=n.step,s=t.as||["bin0","bin1"],u=s[0],o=s[1];return i=t.modified()?(e=e.reflow(!0)).SOURCE:e.modified(E.accessorFields(t.field))?e.ADD_MOD:e.ADD,e.visit(i,function(t){var e=n(t);t[u]=e,t[o]=null==e?null:a+r*(1+(e-a)/r)}),e.modifies(s)},u._bins=function(t){if(this.value&&!t.modified())return this.value;var e,i,n=t.field,a=m.bin(t),r=a.start,s=a.stop,u=a.step;null!=(e=t.anchor)&&(i=e-(r+u*Math.floor((e-r)/u)),r+=i,s+=i);var o=function(t){var e=n(t);return null==e?null:(e=Math.max(r,Math.min(+e,s-u)),r+u*Math.floor((e-r)/u))};return o.start=r,o.stop=s,o.step=u,this.value=E.accessor(o,E.accessorFields(n),t.name||"bin_"+E.accessorName(n))},h.Definition={type:"Collect",metadata:{source:!0},params:[{name:"sort",type:"compare"}]},E.inherits(h,b.Transform).transform=function(t,e){var i=e.fork(e.ALL),n=c(b.tupleid,this.value,i.materialize(i.ADD).add),a=t.sort,r=e.changed()||a&&(t.modified("sort")||e.modified(a.fields));return i.visit(i.REM,n.remove),this.modified(r),this.value=i.source=n.data(a,r),e.source&&e.source.root&&(this.value.root=e.source.root),i},E.inherits(p,b.Operator),y.Definition={type:"CountPattern",metadata:{generates:!0,changes:!0},params:[{name:"field",type:"field",required:!0},{name:"case",type:"enum",values:["upper","lower","mixed"],default:"mixed"},{name:"pattern",type:"string",default:'[\\w"]+'},{name:"stopwords",type:"string",default:""},{name:"as",type:"string",array:!0,length:2,default:["text","count"]}]};var _=E.inherits(y,b.Transform);function x(t){b.Transform.call(this,null,t)}_.transform=function(s,t){function e(r){return function(t){for(var e,i=function(t,e,i){switch(e){case"upper":t=t.toUpperCase();break;case"lower":t=t.toLowerCase()}return t.match(i)}(l(t),s.case,u)||[],n=0,a=i.length;n<a;++n)o.test(e=i[n])||r(e)}}var i=this._parameterCheck(s,t),n=this._counts,u=this._match,o=this._stop,l=s.field,a=s.as||["text","count"],r=e(function(t){n[t]=1+(n[t]||0)}),f=e(function(t){n[t]-=1});return i?t.visit(t.SOURCE,r):(t.visit(t.ADD,r),t.visit(t.REM,f)),this._finish(t,a)},_._parameterCheck=function(t,e){var i=!1;return!t.modified("stopwords")&&this._stop||(this._stop=new RegExp("^"+(t.stopwords||"")+"$","i"),i=!0),!t.modified("pattern")&&this._match||(this._match=new RegExp(t.pattern||"[\\w']+","g"),i=!0),(t.modified("field")||e.modified(t.field.fields))&&(i=!0),i&&(this._counts={}),i},_._finish=function(t,e){var i,n,a,r=this._counts,s=this._tuples||(this._tuples={}),u=e[0],o=e[1],l=t.fork(t.NO_SOURCE|t.NO_FIELDS);for(i in r)n=s[i],a=r[i]||0,!n&&a?(s[i]=n=b.ingest({}),n[u]=i,n[o]=a,l.add.push(n)):0===a?(n&&l.rem.push(n),r[i]=null,s[i]=null):n[o]!==a&&(n[o]=a,l.mod.push(n));return l.modifies(e)},x.Definition={type:"Cross",metadata:{generates:!0},params:[{name:"filter",type:"expr"},{name:"as",type:"string",array:!0,length:2,default:["a","b"]}]},E.inherits(x,b.Transform).transform=function(t,e){var i=e.fork(e.NO_SOURCE),n=this.value,a=t.as||["a","b"],r=a[0],s=a[1];return!n||e.changed(e.ADD_REM)||t.modified("as")||t.modified("filter")?(n&&(i.rem=n),n=e.materialize(e.SOURCE).source,i.add=this.value=function(t,e,i,n){for(var a,r,s=[],u={},o=t.length,l=0;l<o;++l)for(u[e]=r=t[l],a=0;a<o;++a)u[i]=t[a],n(u)&&(s.push(b.ingest(u)),(u={})[e]=r);return s}(n,r,s,t.filter||E.truthy)):i.mod=n,i.source=this.value,i.modifies(a)};var q={kde:m.randomKDE,mixture:m.randomMixture,normal:m.randomNormal,uniform:m.randomUniform},w="distributions",T="function",N="field";function R(t){b.Transform.call(this,null,t)}var M=[{key:{function:"normal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"uniform"},params:[{name:"min",type:"number",default:0},{name:"max",type:"number",default:1}]},{key:{function:"kde"},params:[{name:"field",type:"field",required:!0},{name:"from",type:"data"},{name:"bandwidth",type:"number",default:0}]}],S={key:{function:"mixture"},params:[{name:"distributions",type:"param",array:!0,params:M},{name:"weights",type:"number",array:!0}]};function C(t){b.Operator.call(this,null,A,t),this.modified(!0)}function A(e){var i=e.expr;return this.value&&!e.modified("expr")?this.value:E.accessor(function(t){return i(t,e)},E.accessorFields(i),E.accessorName(i))}function U(t){b.Transform.call(this,[void 0,void 0],t)}function F(t,e){b.Operator.call(this,t),this.parent=e}R.Definition={type:"Density",metadata:{generates:!0},params:[{name:"extent",type:"number",array:!0,length:2},{name:"steps",type:"number",default:100},{name:"method",type:"string",default:"pdf",values:["pdf","cdf"]},{name:"distribution",type:"param",params:M.concat(S)},{name:"as",type:"string",array:!0,default:["value","density"]}]},E.inherits(R,b.Transform).transform=function(t,e){var i,n=e.fork(e.NO_SOURCE|e.NO_FIELDS);if(!this.value||e.changed()||t.modified()){var a=function e(t,i){var n=t[T];q.hasOwnProperty(n)||E.error("Unknown distribution function: "+n);var a=q[n]();for(var r in t)r===N?a.data((t.from||i()).map(t[r])):r===w?a[r](t[r].map(function(t){return e(t,i)})):typeof a[r]===T&&a[r](t[r]);return a}(t.distribution,(i=e,function(){return i.materialize(i.SOURCE).source})),r=t.method||"pdf";"pdf"!==r&&"cdf"!==r&&E.error("Invalid density method: "+r),t.extent||a.data||E.error("Missing density extent parameter."),r=a[r];var s=t.as||["value","density"],u=t.extent||d.extent(a.data()),o=(u[1]-u[0])/(t.steps||100),l=d.range(u[0],u[1]+o/2,o).map(function(t){var e={};return e[s[0]]=t,e[s[1]]=r(t),b.ingest(e)});this.value&&(n.rem=this.value),this.value=n.add=n.source=l}return n},E.inherits(C,b.Operator),U.Definition={type:"Extent",metadata:{},params:[{name:"field",type:"field",required:!0}]},E.inherits(U,b.Transform).transform=function(t,e){var i,n=this.value,a=t.field,r=n[0],s=n[1];((i=e.changed()||e.modified(a.fields)||t.modified("field"))||null==r)&&(r=1/0,s=-1/0),e.visit(i?e.SOURCE:e.ADD,function(t){var e=a(t);null!=e&&((e=+e)<r&&(r=e),s<e&&(s=e))}),isFinite(r)&&isFinite(s)||(r=s=void 0),this.value=[r,s]};var z=E.inherits(F,b.Operator);function L(t){b.Transform.call(this,{},t),this._keys=E.fastmap();var n=this._targets=[];n.active=0,n.forEach=function(t){for(var e=0,i=n.active;e<i;++e)t(n[e],e,n)}}z.connect=function(t){return this.targets().add(t),t.source=this},z.add=function(t){this.value.add.push(t)},z.rem=function(t){this.value.rem.push(t)},z.mod=function(t){this.value.mod.push(t)},z.init=function(t){this.value.init(t,t.NO_SOURCE)},z.evaluate=function(){return this.value};var P=E.inherits(L,b.Transform);function I(t){b.Operator.call(this,null,j,t)}function j(t){return this.value&&!t.modified()?this.value:E.isArray(t.name)?E.array(t.name).map(function(t){return E.field(t)}):E.field(t.name,t.as)}function W(t){b.Transform.call(this,E.fastmap(),t)}function B(t,i){return t?t.map(function(t,e){return i[e]||E.accessorName(t)}):null}function J(t){b.Transform.call(this,[],t)}function K(t){b.Transform.call(this,[],t)}function $(t){b.Transform.call(this,null,t)}function G(t){b.Transform.call(this,[],t)}P.activate=function(t){this._targets[this._targets.active++]=t},P.subflow=function(t,e,i,n){var a,r,s=this.value,u=s.hasOwnProperty(t)&&s[t];return u?u.value.stamp<i.stamp&&(u.init(i),this.activate(u)):(r=n||(r=this._group[t])&&r.tuple,u=(a=i.dataflow).add(new F(i.fork(i.NO_SOURCE),this)).connect(e(a,t,r)),s[t]=u,this.activate(u)),u},P.transform=function(t,e){var i=e.dataflow,n=this,a=t.key,r=t.subflow,s=this._keys,u=t.modified("key");function o(t){return n.subflow(t,r,e)}return this._group=t.group||{},this._targets.active=0,e.visit(e.REM,function(t){var e=b.tupleid(t),i=s.get(e);void 0!==i&&(s.delete(e),o(i).rem(t))}),e.visit(e.ADD,function(t){var e=a(t);s.set(b.tupleid(t),e),o(e).add(t)}),u||e.modified(a.fields)?e.visit(e.MOD,function(t){var e=b.tupleid(t),i=s.get(e),n=a(t);i===n?o(n).mod(t):(s.set(e,n),o(i).rem(t),o(n).add(t))}):e.changed(e.MOD)&&e.visit(e.MOD,function(t){o(s.get(b.tupleid(t))).mod(t)}),u&&e.visit(e.REFLOW,function(t){var e=b.tupleid(t),i=s.get(e),n=a(t);i!==n&&(s.set(e,n),o(i).rem(t),o(n).add(t))}),s.empty>i.cleanThreshold&&i.runAfter(s.clean),e},E.inherits(I,b.Operator),W.Definition={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]},E.inherits(W,b.Transform).transform=function(a,t){var e=t.dataflow,r=this.value,i=t.fork(),s=i.add,u=i.rem,o=i.mod,l=a.expr,f=!0;function n(t){var e=b.tupleid(t),i=l(t,a),n=r.get(e);i&&n?(r.delete(e),s.push(t)):i||n?f&&i&&!n&&o.push(t):(r.set(e,1),u.push(t))}return t.visit(t.REM,function(t){var e=b.tupleid(t);r.has(e)?r.delete(e):u.push(t)}),t.visit(t.ADD,function(t){l(t,a)?s.push(t):r.set(b.tupleid(t),1)}),t.visit(t.MOD,n),a.modified()&&(f=!1,t.visit(t.REFLOW,n)),r.empty>e.cleanThreshold&&e.runAfter(r.clean),i},J.Definition={type:"Flatten",metadata:{generates:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0}]},E.inherits(J,b.Transform).transform=function(t,e){var u=e.fork(e.NO_SOURCE),o=t.fields,l=B(o,t.as||[]),f=l.length;return u.rem=this.value,e.visit(e.SOURCE,function(e){for(var t,i,n,a=o.map(function(t){return t(e)}),r=a.reduce(function(t,e){return Math.max(t,e.length)},0),s=0;s<r;++s){for(i=b.derive(e),t=0;t<f;++t)i[l[t]]=null==(n=a[t][s])?null:n;u.add.push(i)}}),this.value=u.source=u.add,u.modifies(l)},K.Definition={type:"Fold",metadata:{generates:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0,length:2,default:["key","value"]}]},E.inherits(K,b.Transform).transform=function(t,e){var n=e.fork(e.NO_SOURCE),a=t.fields,r=a.map(E.accessorName),i=t.as||["key","value"],s=i[0],u=i[1],o=a.length;return n.rem=this.value,e.visit(e.SOURCE,function(t){for(var e,i=0;i<o;++i)(e=b.derive(t))[s]=r[i],e[u]=a[i](t),n.add.push(e)}),this.value=n.source=n.add,n.modifies(i)},$.Definition={type:"Formula",metadata:{modifies:!0},params:[{name:"expr",type:"expr",required:!0},{name:"as",type:"string",required:!0},{name:"initonly",type:"boolean"}]},E.inherits($,b.Transform).transform=function(e,t){var i=e.expr,n=e.as,a=e.modified(),r=e.initonly?t.ADD:a?t.SOURCE:t.modified(i.fields)?t.ADD_MOD:t.ADD;return a&&(t=t.materialize().reflow(!0)),e.initonly||t.modifies(n),t.visit(r,function(t){t[n]=i(t,e)})},E.inherits(G,b.Transform).transform=function(t,e){var i,n,a,r=this.value,s=e.fork(e.ALL),u=t.size-r.length,o=t.generator;if(0<u){for(i=[];0<=--u;)i.push(a=b.ingest(o(t))),r.push(a);s.add=s.add.length?s.materialize(s.ADD).add.concat(i):i}else n=r.slice(0,-u),s.rem=s.rem.length?s.materialize(s.REM).rem.concat(n):n,r=r.slice(-u);return s.source=this.value=r,s};var H={value:"value",median:d.median,mean:d.mean,min:d.min,max:d.max},Q=[];function V(t){b.Transform.call(this,[],t)}function X(t){a.call(this,t)}V.Definition={type:"Impute",metadata:{changes:!0},params:[{name:"field",type:"field",required:!0},{name:"key",type:"field",required:!0},{name:"keyvals",array:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"enum",default:"value",values:["value","mean","median","max","min"]},{name:"value",default:0}]},E.inherits(V,b.Transform).transform=function(t,e){var i,n,a,r,s,u,o,l,f,d,m,c=e.fork(e.ALL),h=function(t){var e,i=t.method||H.value;if(null!=H[i])return i===H.value?(e=void 0!==t.value?t.value:0,function(){return e}):H[i];E.error("Unrecognized imputation method: "+i)}(t),p=(m=t.field,function(t){return t?m(t):NaN}),v=E.accessorName(t.field),g=E.accessorName(t.key),y=(t.groupby||[]).map(E.accessorName),_=function(t,e,i,n){var a,r,s,u,o,l,f,d,m=function(t){return t(d)},c=[],h=n?n.slice():[],p={},v={};for(h.forEach(function(t,e){p[t]=e+1}),u=0,f=t.length;u<f;++u)d=t[u],l=i(d),o=p[l]||(p[l]=h.push(l)),r=(a=e?e.map(m):Q)+"",(s=v[r])||(s=v[r]=[],c.push(s),s.values=a),s[o-1]=d;return c.domain=h,c}(e.source,t.groupby,t.key,t.keyvals),x=[],O=this.value,D=_.domain.length;for(s=0,l=_.length;s<l;++s)for(a=(i=_[s]).values,n=NaN,o=0;o<D;++o)if(null==i[o]){for(r=_.domain[o],d={_impute:!0},u=0,f=a.length;u<f;++u)d[y[u]]=a[u];d[g]=r,d[v]=isNaN(n)?n=h(i,p):n,x.push(b.ingest(d))}return x.length&&(c.add=c.materialize(c.ADD).add.concat(x)),O.length&&(c.rem=c.materialize(c.REM).rem.concat(O)),this.value=x,c},X.Definition={type:"JoinAggregate",metadata:{modifies:!0},params:[{name:"groupby",type:"field",array:!0},{name:"fields",type:"field",null:!0,array:!0},{name:"ops",type:"enum",array:!0,values:e},{name:"as",type:"string",null:!0,array:!0},{name:"key",type:"field"}]};var Y=E.inherits(X,a);function Z(t){b.Operator.call(this,null,tt,t)}function tt(t){return this.value&&!t.modified()?this.value:E.key(t.fields,t.flat)}function et(t){b.Transform.call(this,null,t)}function it(t){b.Transform.call(this,{},t)}function nt(t){b.Operator.call(this,null,at,t)}function at(t){if(this.value&&!t.modified())return this.value;var e,i,n,a=1/0,r=-1/0,s=t.extents;for(e=0,i=s.length;e<i;++e)(n=s[e])[0]<a&&(a=n[0]),n[1]>r&&(r=n[1]);return[a,r]}function rt(t){b.Operator.call(this,null,st,t)}function st(t){return this.value&&!t.modified()?this.value:t.values.reduce(function(t,e){return t.concat(e)},[])}function ut(t){b.Transform.call(this,null,t)}function ot(t){a.call(this,t)}Y.transform=function(t,e){var i,n=this,a=t.modified();return n.value&&(a||e.modified(n._inputs))?(i=n.value=a?n.init(t):{},e.visit(e.SOURCE,function(t){n.add(t)})):(i=n.value=n.value||this.init(t),e.visit(e.REM,function(t){n.rem(t)}),e.visit(e.ADD,function(t){n.add(t)})),n.changes(),e.visit(e.SOURCE,function(t){E.extend(t,i[n.cellkey(t)].tuple)}),e.reflow(a).modifies(this._outputs)},Y.changes=function(){var t,e,i=this._adds,n=this._mods;for(t=0,e=this._alen;t<e;++t)this.celltuple(i[t]),i[t]=null;for(t=0,e=this._mlen;t<e;++t)this.celltuple(n[t]),n[t]=null;this._alen=this._mlen=0},E.inherits(Z,b.Operator),E.inherits(et,b.Transform).transform=function(t,e){e.dataflow.request(this.target,t.url,t.format)},it.Definition={type:"Lookup",metadata:{modifies:!0},params:[{name:"index",type:"index",params:[{name:"from",type:"data",required:!0},{name:"key",type:"field",required:!0}]},{name:"values",type:"field",array:!0},{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0},{name:"default",default:null}]},E.inherits(it,b.Transform).transform=function(t,e){var i,r,n=e,s=t.as,u=t.fields,o=t.index,l=t.values,f=null==t.default?null:t.default,a=t.modified(),d=a?e.SOURCE:e.ADD,m=u.length;return i=l?(r=l.length,1<m&&!s&&E.error('Multi-field lookup requires explicit "as" parameter.'),s&&s.length!==m*r&&E.error('The "as" parameter has too few output field names.'),s=s||l.map(E.accessorName),function(t){for(var e,i,n=0,a=0;n<m;++n)if(null==(i=o.get(u[n](t))))for(e=0;e<r;++e,++a)t[s[a]]=f;else for(e=0;e<r;++e,++a)t[s[a]]=l[e](i)}):(s||E.error("Missing output field names."),function(t){for(var e,i=0;i<m;++i)e=o.get(u[i](t)),t[s[i]]=null==e?f:e}),a?n=e.reflow(!0):d|=u.some(function(t){return e.modified(t.fields)})?e.MOD:0,e.visit(d,i),n.modifies(s)},E.inherits(nt,b.Operator),E.inherits(rt,b.Operator),E.inherits(ut,b.Transform),ut.prototype.transform=function(t,e){return this.modified(t.modified()),this.value=t,e.fork(e.NO_SOURCE|e.NO_FIELDS)},ot.Definition={type:"Pivot",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"field",type:"field",required:!0},{name:"value",type:"field",required:!0},{name:"op",type:"enum",values:e,default:"sum"},{name:"limit",type:"number",default:0},{name:"key",type:"field"}]};var lt=E.inherits(ot,a);function ft(t){L.call(this,t)}function dt(t){b.Transform.call(this,null,t)}function mt(t){b.Transform.call(this,null,t)}function ct(t){b.Transform.call(this,null,t)}function ht(t){b.Transform.call(this,[],t),this.count=0}function pt(t){b.Transform.call(this,null,t)}function vt(t){b.Transform.call(this,null,t),this.modified(!0)}function gt(t){b.Transform.call(this,E.fastmap(),t)}function yt(t){b.Transform.call(this,null,t)}lt._transform=lt.transform,lt.transform=function(t,e){return this._transform((n=e,r=(i=t).field,s=i.value,a=("count"===i.op?"__count__":i.op)||"sum",u=E.accessorFields(r).concat(E.accessorFields(s)),l=r,f=i.limit||0,m={},c=[],(d=n).visit(d.SOURCE,function(t){var e=l(t);m[e]||(m[e]=1,c.push(e))}),c.sort(function(t,e){return(t<e||null==t)&&null!=e?-1:(e<t||null==e)&&null!=t?1:(e=e instanceof Date?+e:e,(t=t instanceof Date?+t:t)!==t&&e==e?-1:e!=e&&t==t?1:0)}),o=f?c.slice(0,f):c,{key:i.key,groupby:i.groupby,ops:o.map(function(){return a}),fields:o.map(function(t){return e=t,i=r,n=s,a=u,E.accessor(function(t){return i(t)===e?n(t):NaN},a,e+"");var e,i,n,a}),as:o.map(function(t){return t+""}),modified:i.modified.bind(i)}),e);var i,n,r,s,a,u,o,l,f,d,m,c},E.inherits(ft,L).transform=function(t,i){var n=this,a=t.subflow,r=t.field;return(t.modified("field")||r&&i.modified(E.accessorFields(r)))&&E.error("PreFacet does not support field modification."),this._targets.active=0,i.visit(i.MOD,function(t){var e=n.subflow(b.tupleid(t),a,i,t);r?r(t).forEach(function(t){e.mod(t)}):e.mod(t)}),i.visit(i.ADD,function(t){var e=n.subflow(b.tupleid(t),a,i,t);r?r(t).forEach(function(t){e.add(b.ingest(t))}):e.add(t)}),i.visit(i.REM,function(t){var e=n.subflow(b.tupleid(t),a,i,t);r?r(t).forEach(function(t){e.rem(t)}):e.rem(t)}),i},dt.Definition={type:"Project",metadata:{generates:!0,changes:!0},params:[{name:"fields",type:"field",array:!0},{name:"as",type:"string",null:!0,array:!0}]},E.inherits(dt,b.Transform).transform=function(t,e){var i,n,a=t.fields,r=B(t.fields,t.as||[]),s=a?function(t,e){return function(t,e,i,n){for(var a=0,r=i.length;a<r;++a)e[n[a]]=i[a](t);return e}(t,e,a,r)}:b.rederive;return n=this.value?this.value:(e=e.addAll(),this.value={}),i=e.fork(e.NO_SOURCE),e.visit(e.REM,function(t){var e=b.tupleid(t);i.rem.push(n[e]),n[e]=null}),e.visit(e.ADD,function(t){var e=s(t,b.ingest({}));n[b.tupleid(t)]=e,i.add.push(e)}),e.visit(e.MOD,function(t){i.mod.push(s(t,n[b.tupleid(t)]))}),i},E.inherits(mt,b.Transform).transform=function(t,e){return this.value=t.value,t.modified("value")?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation},E.inherits(ct,b.Transform).transform=function(t,e){var i,n;return n=this.value?this.value:(i=e=e.addAll(),this.value={}),t.derive&&(i=e.fork(e.NO_SOURCE),e.visit(e.REM,function(t){var e=b.tupleid(t);i.rem.push(n[e]),n[e]=null}),e.visit(e.ADD,function(t){var e=b.derive(t);n[b.tupleid(t)]=e,i.add.push(e)}),e.visit(e.MOD,function(t){i.mod.push(b.rederive(t,n[b.tupleid(t)]))})),i},ht.Definition={type:"Sample",metadata:{},params:[{name:"size",type:"number",default:1e3}]},E.inherits(ht,b.Transform).transform=function(t,e){var n=e.fork(e.NO_SOURCE),i=t.modified("size"),a=t.size,r=this.value,s=this.count,u=0,o=r.reduce(function(t,e){return t[b.tupleid(e)]=1,t},{});function l(t){var e,i;r.length<a?r.push(t):(i=~~((s+1)*m.random()))<r.length&&u<=i&&(e=r[i],o[b.tupleid(e)]&&n.rem.push(e),r[i]=t),++s}if(e.rem.length&&(e.visit(e.REM,function(t){var e=b.tupleid(t);o[e]&&(o[e]=-1,n.rem.push(t)),--s}),r=r.filter(function(t){return-1!==o[b.tupleid(t)]})),(e.rem.length||i)&&r.length<a&&e.source&&(u=s=r.length,e.visit(e.SOURCE,function(t){o[b.tupleid(t)]||l(t)}),u=-1),i&&r.length>a){for(var f=0,d=r.length-a;f<d;++f)o[b.tupleid(r[f])]=-1,n.rem.push(r[f]);r=r.slice(d)}return e.mod.length&&e.visit(e.MOD,function(t){o[b.tupleid(t)]&&n.mod.push(t)}),e.add.length&&e.visit(e.ADD,l),(e.add.length||u<0)&&(n.add=r.filter(function(t){return!o[b.tupleid(t)]})),this.count=s,this.value=n.source=r,n},pt.Definition={type:"Sequence",metadata:{changes:!0},params:[{name:"start",type:"number",required:!0},{name:"stop",type:"number",required:!0},{name:"step",type:"number",default:1},{name:"as",type:"string",default:"data"}]},E.inherits(pt,b.Transform).transform=function(t,e){if(!this.value||t.modified()){var i=e.materialize().fork(e.MOD),n=t.as||"data";return i.rem=this.value?e.rem.concat(this.value):e.rem,this.value=d.range(t.start,t.stop,t.step||1).map(function(t){var e={};return e[n]=t,b.ingest(e)}),i.add=e.add.concat(this.value),i}},E.inherits(vt,b.Transform).transform=function(t,e){return this.value=e.source,e.changed()?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation},E.inherits(gt,b.Transform).transform=function(t,e){var i=e.dataflow,n=t.field,a=this.value,r=!0;function s(t){a.set(n(t),t)}return t.modified("field")||e.modified(n.fields)?(a.clear(),e.visit(e.SOURCE,s)):e.changed()?(e.visit(e.REM,function(t){a.delete(n(t))}),e.visit(e.ADD,s)):r=!1,this.modified(r),a.empty>i.cleanThreshold&&i.runAfter(a.clean),e.fork()},E.inherits(yt,b.Transform).transform=function(t,e){(!this.value||t.modified("field")||t.modified("sort")||e.changed()||t.sort&&e.modified(t.sort.fields))&&(this.value=(t.sort?e.source.slice().sort(t.sort):e.source).map(t.field))};var _t={row_number:function(){return{next:function(t){return t.index+1}}},rank:function(){var n;return{init:function(){n=1},next:function(t){var e=t.index,i=t.data;return e&&t.compare(i[e-1],i[e])?n=e+1:n}}},dense_rank:function(){var n;return{init:function(){n=1},next:function(t){var e=t.index,i=t.data;return e&&t.compare(i[e-1],i[e])?++n:n}}},percent_rank:function(){var t=_t.rank(),e=t.next;return{init:t.init,next:function(t){return(e(t)-1)/(t.data.length-1)}}},cume_dist:function(){var a;return{init:function(){a=0},next:function(t){var e=t.index,i=t.data,n=t.compare;if(a<e){for(;e+1<i.length&&!n(i[e],i[e+1]);)++e;a=e}return(1+a)/i.length}}},ntile:function(t,e){0<(e=+e)||E.error("ntile num must be greater than zero.");var i=_t.cume_dist(),n=i.next;return{init:i.init,next:function(t){return Math.ceil(e*n(t))}}},lag:function(i,n){return n=+n||1,{next:function(t){var e=t.index-n;return 0<=e?i(t.data[e]):null}}},lead:function(n,a){return a=+a||1,{next:function(t){var e=t.index+a,i=t.data;return e<i.length?n(i[e]):null}}},first_value:function(e){return{next:function(t){return e(t.data[t.i0])}}},last_value:function(e){return{next:function(t){return e(t.data[t.i1-1])}}},nth_value:function(i,n){return 0<(n=+n)||E.error("nth_value nth must be greater than zero."),{next:function(t){var e=t.i0+(n-1);return e<t.i1?i(t.data[e]):null}}}},xt=Object.keys(_t);function Ot(t){var e=E.array(t.ops),d=E.array(t.fields),m=E.array(t.params),c=E.array(t.as),h=this.outputs=[],p=this.windows=[],i={},v={},g=!0,y=[],_=[];function x(t){E.array(E.accessorFields(t)).forEach(function(t){i[t]=1})}x(t.sort),e.forEach(function(t,e){var i,n,a,r,s,u=d[e],o=E.accessorName(u),l=O(t,o,c[e]);if(x(u),h.push(l),_t.hasOwnProperty(t))p.push((i=t,n=d[e],a=m[e],r=l,{init:(s=_t[i](n,a)).init||E.zero,update:function(t,e){e[r]=s.next(t)}}));else{if(null==u&&"count"!==t&&E.error("Null aggregate field specified."),"count"===t)return void y.push(l);g=!1;var f=v[o];f||((f=v[o]=[]).field=u,_.push(f)),f.push(D(t,l))}}),(y.length||_.length)&&(this.cell=function(t,n,a){t=t.map(function(t){return k(t,t.field)});var r={num:0,agg:null,store:!1,count:n};if(!a)for(var i=t.length,s=r.agg=Array(i),e=0;e<i;++e)s[e]=new t[e](r);if(r.store)var u=r.data=new o;return r.add=function(t){if(r.num+=1,!a){u&&u.add(t);for(var e=0;e<i;++e)s[e].add(s[e].get(t),t)}},r.rem=function(t){if(r.num-=1,!a){u&&u.rem(t);for(var e=0;e<i;++e)s[e].rem(s[e].get(t),t)}},r.set=function(t){var e,i;for(u&&u.values(),e=0,i=n.length;e<i;++e)t[n[e]]=r.num;if(!a)for(e=0,i=s.length;e<i;++e)s[e].set(t)},r.init=function(){r.num=0,u&&u.reset();for(var t=0;t<i;++t)s[t].init()},r}(_,y,g)),this.inputs=Object.keys(i)}var Dt=Ot.prototype;function bt(t){b.Transform.call(this,{},t),this._mlen=0,this._mods=[]}Dt.init=function(){this.windows.forEach(function(t){t.init()}),this.cell&&this.cell.init()},Dt.update=function(t,e){var i,n=this.cell,a=this.windows,r=t.data,s=a&&a.length;if(n){for(i=t.p0;i<t.i0;++i)n.rem(r[i]);for(i=t.p1;i<t.i1;++i)n.add(r[i]);n.set(e)}for(i=0;i<s;++i)a[i].update(t,e)},bt.Definition={type:"Window",metadata:{modifies:!0},params:[{name:"sort",type:"compare"},{name:"groupby",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:xt.concat(e)},{name:"params",type:"number",null:!0,array:!0},{name:"fields",type:"field",null:!0,array:!0},{name:"as",type:"string",null:!0,array:!0},{name:"frame",type:"number",null:!0,array:!0,length:2,default:[null,0]},{name:"ignorePeers",type:"boolean",default:!1}]};var Et=E.inherits(bt,b.Transform);function kt(t,e,i){var n=i.sort,a=n&&!i.ignorePeers,r=i.frame||[null,0],s=t.data(n),u=s.length,o=0,l=a?d.bisector(n):null,f={i0:0,i1:0,p0:0,p1:0,index:0,data:s,compare:n||E.constant(-1)};for(e.init();o<u;++o)qt(f,r,o,u),a&&wt(f,l),e.update(f,s[o])}function qt(t,e,i,n){t.p0=t.i0,t.p1=t.i1,t.i0=null==e[0]?0:Math.max(0,i-Math.abs(e[0])),t.i1=null==e[1]?n:Math.min(n,i+Math.abs(e[1])+1),t.index=i}function wt(t,e){var i=t.i0,n=t.i1-1,a=t.compare,r=t.data,s=r.length-1;0<i&&!a(r[i],r[i-1])&&(t.i0=e.left(r,r[i])),n<s&&!a(r[n],r[n+1])&&(t.i1=e.right(r,r[n]))}Et.transform=function(t,e){var i,n,a=this,r=a.state,s=t.modified();this.stamp=e.stamp,r&&!s||(r=a.state=new Ot(t));var u=v(t.groupby);function o(t){return a.group(u(t))}for(s||e.modified(r.inputs)?(a.value={},e.visit(e.SOURCE,function(t){o(t).add(t)})):(e.visit(e.REM,function(t){o(t).remove(t)}),e.visit(e.ADD,function(t){o(t).add(t)})),i=0,n=a._mlen;i<n;++i)kt(a._mods[i],r,t);return a._mlen=0,a._mods=[],e.reflow(s).modifies(r.outputs)},Et.group=function(t){var e=this,i=e.value[t];return i||((i=e.value[t]=c(b.tupleid)).stamp=-1),i.stamp<e.stamp&&(i.stamp=e.stamp,e._mods[e._mlen++]=i),i},t.aggregate=a,t.bin=s,t.collect=h,t.compare=p,t.countpattern=y,t.cross=x,t.density=R,t.expression=C,t.extent=U,t.facet=L,t.field=I,t.filter=W,t.flatten=J,t.fold=K,t.formula=$,t.generate=G,t.impute=V,t.joinaggregate=X,t.key=Z,t.load=et,t.lookup=it,t.multiextent=nt,t.multivalues=rt,t.params=ut,t.pivot=ot,t.prefacet=ft,t.project=dt,t.proxy=mt,t.relay=ct,t.sample=ht,t.sequence=pt,t.sieve=vt,t.subflow=F,t.tupleindex=gt,t.values=yt,t.window=bt,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vega-util"),require("vega-dataflow"),require("vega-statistics"),require("d3-array")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-dataflow","vega-statistics","d3-array"],e):e(((t=t||self).vega=t.vega||{},t.vega.transforms={}),t.vega,t.vega,t.vega,t.d3)}(this,function(t,e,i,n,r){"use strict";function a(t){return t&&t.length?1===t.length?t[0]:(e=t,function(t){for(var i=e.length,n=1,r=String(e[0](t));n<i;++n)r+="|"+e[n](t);return r}):function(){return""};var e}function s(t,e,i){return i||t+(e?"_"+e:"")}var u={values:f({name:"values",init:"cell.store = true;",set:"cell.data.values()",idx:-1}),count:f({name:"count",set:"cell.num"}),__count__:f({name:"count",set:"this.missing + this.valid"}),missing:f({name:"missing",set:"this.missing"}),valid:f({name:"valid",set:"this.valid"}),sum:f({name:"sum",init:"this.sum = 0;",add:"this.sum += +v;",rem:"this.sum -= v;",set:"this.sum"}),mean:f({name:"mean",init:"this.mean = 0;",add:"var d = v - this.mean; this.mean += d / this.valid;",rem:"var d = v - this.mean; this.mean -= this.valid ? d / this.valid : this.mean;",set:"this.valid ? this.mean : undefined"}),average:f({name:"average",set:"this.valid ? this.mean : undefined",req:["mean"],idx:1}),variance:f({name:"variance",init:"this.dev = 0;",add:"this.dev += d * (v - this.mean);",rem:"this.dev -= d * (v - this.mean);",set:"this.valid > 1 ? this.dev / (this.valid-1) : undefined",req:["mean"],idx:1}),variancep:f({name:"variancep",set:"this.valid > 1 ? this.dev / this.valid : undefined",req:["variance"],idx:2}),stdev:f({name:"stdev",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid-1)) : undefined",req:["variance"],idx:2}),stdevp:f({name:"stdevp",set:"this.valid > 1 ? Math.sqrt(this.dev / this.valid) : undefined",req:["variance"],idx:2}),stderr:f({name:"stderr",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid * (this.valid-1))) : undefined",req:["variance"],idx:2}),distinct:f({name:"distinct",set:"cell.data.distinct(this.get)",req:["values"],idx:3}),ci0:f({name:"ci0",set:"cell.data.ci0(this.get)",req:["values"],idx:3}),ci1:f({name:"ci1",set:"cell.data.ci1(this.get)",req:["values"],idx:3}),median:f({name:"median",set:"cell.data.q2(this.get)",req:["values"],idx:3}),q1:f({name:"q1",set:"cell.data.q1(this.get)",req:["values"],idx:3}),q3:f({name:"q3",set:"cell.data.q3(this.get)",req:["values"],idx:3}),argmin:f({name:"argmin",init:"this.argmin = undefined;",add:"if (v < this.min) this.argmin = t;",rem:"if (v <= this.min) this.argmin = undefined;",set:"this.argmin || cell.data.argmin(this.get)",req:["min"],str:["values"],idx:3}),argmax:f({name:"argmax",init:"this.argmax = undefined;",add:"if (v > this.max) this.argmax = t;",rem:"if (v >= this.max) this.argmax = undefined;",set:"this.argmax || cell.data.argmax(this.get)",req:["max"],str:["values"],idx:3}),min:f({name:"min",init:"this.min = undefined;",add:"if (v < this.min || this.min === undefined) this.min = v;",rem:"if (v <= this.min) this.min = NaN;",set:"this.min = (isNaN(this.min) ? cell.data.min(this.get) : this.min)",str:["values"],idx:4}),max:f({name:"max",init:"this.max = undefined;",add:"if (v > this.max || this.max === undefined) this.max = v;",rem:"if (v >= this.max) this.max = NaN;",set:"this.max = (isNaN(this.max) ? cell.data.max(this.get) : this.max)",str:["values"],idx:4})},o=Object.keys(u);function l(t,e){return u[t](e)}function f(t){return function(i){var n=e.extend({init:"",add:"",rem:"",idx:0},t);return n.out=i||t.name,n}}function d(t,e){return t.idx-e.idx}function m(t,i){var n=i||e.identity,r=function(t,e){var i,n=t.reduce(function t(i,n){function r(e){i[e]||t(i,i[e]=u[e]())}return n.req&&n.req.forEach(r),e&&n.str&&n.str.forEach(r),i},t.reduce(function(t,e){return t[e.name]=e,t},{})),r=[];for(i in n)r.push(n[i]);return r.sort(d)}(t,!0),a="var cell = this.cell; this.valid = 0; this.missing = 0;",s="this.cell = cell; this.init();",o="if(v==null){++this.missing; return;} if(v!==v) return; ++this.valid;",l="if(v==null){--this.missing; return;} if(v!==v) return; --this.valid;",f="var cell = this.cell;";return r.forEach(function(t){a+=t.init,o+=t.add,l+=t.rem}),t.slice().sort(d).forEach(function(t){f+="t['"+t.out+"']="+t.set+";"}),f+="return t;",(s=Function("cell",s)).prototype.init=Function(a),s.prototype.add=Function("v","t",o),s.prototype.rem=Function("v","t",l),s.prototype.set=Function("t",f),s.prototype.get=n,s.fields=t.map(function(t){return t.out}),s}function c(t){this._key=t?e.field(t):i.tupleid,this.reset()}var h=c.prototype;function p(t){i.Transform.call(this,null,t),this._adds=[],this._mods=[],this._alen=0,this._mlen=0,this._drop=!0,this._cross=!1,this._dims=[],this._dnames=[],this._measures=[],this._countOnly=!1,this._counts=null,this._prev=null,this._inputs=null,this._outputs=null}h.reset=function(){this._add=[],this._rem=[],this._ext=null,this._get=null,this._q=null},h.add=function(t){this._add.push(t)},h.rem=function(t){this._rem.push(t)},h.values=function(){if(this._get=null,0===this._rem.length)return this._add;var t,e,i,n=this._add,r=this._rem,a=this._key,s=n.length,u=r.length,o=Array(s-u),l={};for(t=0;t<u;++t)l[a(r[t])]=1;for(t=0,e=0;t<s;++t)l[a(i=n[t])]?l[a(i)]=0:o[e++]=i;return this._rem=[],this._add=o},h.distinct=function(t){for(var e,i=this.values(),n=i.length,r={},a=0;--n>=0;)e=t(i[n])+"",r.hasOwnProperty(e)||(r[e]=1,++a);return a},h.extent=function(t){if(this._get!==t||!this._ext){var i=this.values(),n=e.extentIndex(i,t);this._ext=[i[n[0]],i[n[1]]],this._get=t}return this._ext},h.argmin=function(t){return this.extent(t)[0]||{}},h.argmax=function(t){return this.extent(t)[1]||{}},h.min=function(t){var e=this.extent(t)[0];return null!=e?t(e):void 0},h.max=function(t){var e=this.extent(t)[1];return null!=e?t(e):void 0},h.quartile=function(t){return this._get===t&&this._q||(this._q=n.quartiles(this.values(),t),this._get=t),this._q},h.q1=function(t){return this.quartile(t)[0]},h.q2=function(t){return this.quartile(t)[1]},h.q3=function(t){return this.quartile(t)[2]},h.ci=function(t){return this._get===t&&this._ci||(this._ci=n.bootstrapCI(this.values(),1e3,.05,t),this._get=t),this._ci},h.ci0=function(t){return this.ci(t)[0]},h.ci1=function(t){return this.ci(t)[1]},p.Definition={type:"Aggregate",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:o},{name:"fields",type:"field",null:!0,array:!0},{name:"as",type:"string",null:!0,array:!0},{name:"drop",type:"boolean",default:!0},{name:"cross",type:"boolean",default:!1},{name:"key",type:"field"}]};var v=e.inherits(p,i.Transform);function g(t){i.Transform.call(this,null,t)}v.transform=function(t,e){var i,n=this,r=e.fork(e.NO_SOURCE|e.NO_FIELDS);return this.stamp=r.stamp,this.value&&((i=t.modified())||e.modified(this._inputs))?(this._prev=this.value,this.value=i?this.init(t):{},e.visit(e.SOURCE,function(t){n.add(t)})):(this.value=this.value||this.init(t),e.visit(e.REM,function(t){n.rem(t)}),e.visit(e.ADD,function(t){n.add(t)})),r.modifies(this._outputs),n._drop=!1!==t.drop,t.cross&&n._dims.length>1&&(n._drop=!1,this.cross()),n.changes(r)},v.cross=function(){var t=this,e=t.value,i=t._dnames,n=i.map(function(){return{}}),r=i.length;function a(t){var e,a,s,u;for(e in t)for(s=t[e].tuple,a=0;a<r;++a)n[a][u=s[i[a]]]=u}a(t._prev),a(e),function a(s,u,o){var l,f,d=i[o],m=n[o++];for(l in m)u[d]=m[l],f=s?s+"|"+l:l,o<r?a(f,u,o):e[f]||t.cell(f,u)}("",{},0)},v.init=function(t){var i=this._inputs=[],n=this._outputs=[],r={};function u(t){for(var n,a=e.array(e.accessorFields(t)),s=0,u=a.length;s<u;++s)r[n=a[s]]||(r[n]=1,i.push(n))}this._dims=e.array(t.groupby),this._dnames=this._dims.map(function(t){var i=e.accessorName(t);return u(t),n.push(i),i}),this.cellkey=t.key?t.key:a(this._dims),this._countOnly=!0,this._counts=[],this._measures=[];var o,f,d,c,h,p,v=t.fields||[null],g=t.ops||["count"],y=t.as||[],_=v.length,x={};for(_!==g.length&&e.error("Unmatched number of fields and aggregate ops."),p=0;p<_;++p)o=v[p],f=g[p],null==o&&"count"!==f&&e.error("Null aggregate field specified."),h=s(f,c=e.accessorName(o),y[p]),n.push(h),"count"!==f?((d=x[c])||(u(o),(d=x[c]=[]).field=o,this._measures.push(d)),"count"!==f&&(this._countOnly=!1),d.push(l(f,h))):this._counts.push(h);return this._measures=this._measures.map(function(t){return m(t,t.field)}),{}},v.cellkey=a(),v.cell=function(t,e){var i=this.value[t];return i?0===i.num&&this._drop&&i.stamp<this.stamp?(i.stamp=this.stamp,this._adds[this._alen++]=i):i.stamp<this.stamp&&(i.stamp=this.stamp,this._mods[this._mlen++]=i):(i=this.value[t]=this.newcell(t,e),this._adds[this._alen++]=i),i},v.newcell=function(t,e){var i={key:t,num:0,agg:null,tuple:this.newtuple(e,this._prev&&this._prev[t]),stamp:this.stamp,store:!1};if(!this._countOnly){var n,r=this._measures,a=r.length;for(i.agg=Array(a),n=0;n<a;++n)i.agg[n]=new r[n](i)}return i.store&&(i.data=new c),i},v.newtuple=function(t,e){var n,r,a=this._dnames,s=this._dims,u={};for(n=0,r=s.length;n<r;++n)u[a[n]]=s[n](t);return e?i.replace(e.tuple,u):i.ingest(u)},v.add=function(t){var e,i,n,r=this.cellkey(t),a=this.cell(r,t);if(a.num+=1,!this._countOnly)for(a.store&&a.data.add(t),i=0,n=(e=a.agg).length;i<n;++i)e[i].add(e[i].get(t),t)},v.rem=function(t){var e,i,n,r=this.cellkey(t),a=this.cell(r,t);if(a.num-=1,!this._countOnly)for(a.store&&a.data.rem(t),i=0,n=(e=a.agg).length;i<n;++i)e[i].rem(e[i].get(t),t)},v.celltuple=function(t){var e,i,n,r=t.tuple,a=this._counts;for(t.store&&t.data.values(),i=0,n=a.length;i<n;++i)r[a[i]]=t.num;if(!this._countOnly)for(i=0,n=(e=t.agg).length;i<n;++i)e[i].set(r);return r},v.changes=function(t){var e,i,n,r,a=this._adds,s=this._mods,u=this._prev,o=this._drop,l=t.add,f=t.rem,d=t.mod;if(u)for(i in u)e=u[i],o&&!e.num||f.push(e.tuple);for(n=0,r=this._alen;n<r;++n)l.push(this.celltuple(a[n])),a[n]=null;for(n=0,r=this._mlen;n<r;++n)(0===(e=s[n]).num&&o?f:d).push(this.celltuple(e)),s[n]=null;return this._alen=this._mlen=0,this._prev=null,t},g.Definition={type:"Bin",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"anchor",type:"number"},{name:"maxbins",type:"number",default:20},{name:"base",type:"number",default:10},{name:"divide",type:"number",array:!0,default:[5,2]},{name:"extent",type:"number",array:!0,length:2,required:!0},{name:"step",type:"number"},{name:"steps",type:"number",array:!0},{name:"minstep",type:"number",default:0},{name:"nice",type:"boolean",default:!0},{name:"name",type:"string"},{name:"as",type:"string",array:!0,length:2,default:["bin0","bin1"]}]};var y=e.inherits(g,i.Transform);function _(t,i,n){var r=t,a=i||[],s=n||[],u={},o=0;return{add:function(t){s.push(t)},remove:function(t){u[r(t)]=++o},size:function(){return a.length},data:function(t,i){return o&&(a=a.filter(function(t){return!u[r(t)]}),u={},o=0),i&&t&&a.sort(t),s.length&&(a=t?e.merge(t,a,s.sort(t)):a.concat(s),s=[]),a}}}function x(t){i.Transform.call(this,[],t)}function O(t){i.Operator.call(this,null,D,t)}function D(t){return this.value&&!t.modified()?this.value:e.compare(t.fields,t.orders)}function b(t){i.Transform.call(this,null,t)}y.transform=function(t,i){var n,r=this._bins(t),a=r.start,s=r.step,u=t.as||["bin0","bin1"],o=u[0],l=u[1];return n=t.modified()?(i=i.reflow(!0)).SOURCE:i.modified(e.accessorFields(t.field))?i.ADD_MOD:i.ADD,i.visit(n,function(t){var e=r(t);t[o]=e,t[l]=null==e?null:a+s*(1+(e-a)/s)}),i.modifies(u)},y._bins=function(t){if(this.value&&!t.modified())return this.value;var i,r,a=t.field,s=n.bin(t),u=s.start,o=s.stop,l=s.step;null!=(i=t.anchor)&&(r=i-(u+l*Math.floor((i-u)/l)),u+=r,o+=r);var f=function(t){var e=a(t);return null==e?null:(e=Math.max(u,Math.min(+e,o-l)),u+l*Math.floor((e-u)/l))};return f.start=u,f.stop=o,f.step=l,this.value=e.accessor(f,e.accessorFields(a),t.name||"bin_"+e.accessorName(a))},x.Definition={type:"Collect",metadata:{source:!0},params:[{name:"sort",type:"compare"}]},e.inherits(x,i.Transform).transform=function(t,e){var n=e.fork(e.ALL),r=_(i.tupleid,this.value,n.materialize(n.ADD).add),a=t.sort,s=e.changed()||a&&(t.modified("sort")||e.modified(a.fields));return n.visit(n.REM,r.remove),this.modified(s),this.value=n.source=r.data(a,s),e.source&&e.source.root&&(this.value.root=e.source.root),n},e.inherits(O,i.Operator),b.Definition={type:"CountPattern",metadata:{generates:!0,changes:!0},params:[{name:"field",type:"field",required:!0},{name:"case",type:"enum",values:["upper","lower","mixed"],default:"mixed"},{name:"pattern",type:"string",default:'[\\w"]+'},{name:"stopwords",type:"string",default:""},{name:"as",type:"string",array:!0,length:2,default:["text","count"]}]};var E=e.inherits(b,i.Transform);function k(t){i.Transform.call(this,null,t)}E.transform=function(t,e){function i(e){return function(i){for(var n,r=function(t,e,i){switch(e){case"upper":t=t.toUpperCase();break;case"lower":t=t.toLowerCase()}return t.match(i)}(u(i),t.case,a)||[],o=0,l=r.length;o<l;++o)s.test(n=r[o])||e(n)}}var n=this._parameterCheck(t,e),r=this._counts,a=this._match,s=this._stop,u=t.field,o=t.as||["text","count"],l=i(function(t){r[t]=1+(r[t]||0)}),f=i(function(t){r[t]-=1});return n?e.visit(e.SOURCE,l):(e.visit(e.ADD,l),e.visit(e.REM,f)),this._finish(e,o)},E._parameterCheck=function(t,e){var i=!1;return!t.modified("stopwords")&&this._stop||(this._stop=new RegExp("^"+(t.stopwords||"")+"$","i"),i=!0),!t.modified("pattern")&&this._match||(this._match=new RegExp(t.pattern||"[\\w']+","g"),i=!0),(t.modified("field")||e.modified(t.field.fields))&&(i=!0),i&&(this._counts={}),i},E._finish=function(t,e){var n,r,a,s=this._counts,u=this._tuples||(this._tuples={}),o=e[0],l=e[1],f=t.fork(t.NO_SOURCE|t.NO_FIELDS);for(n in s)r=u[n],a=s[n]||0,!r&&a?(u[n]=r=i.ingest({}),r[o]=n,r[l]=a,f.add.push(r)):0===a?(r&&f.rem.push(r),s[n]=null,u[n]=null):r[l]!==a&&(r[l]=a,f.mod.push(r));return f.modifies(e)},k.Definition={type:"Cross",metadata:{generates:!0},params:[{name:"filter",type:"expr"},{name:"as",type:"string",array:!0,length:2,default:["a","b"]}]},e.inherits(k,i.Transform).transform=function(t,n){var r=n.fork(n.NO_SOURCE),a=this.value,s=t.as||["a","b"],u=s[0],o=s[1];return!a||n.changed(n.ADD_REM)||t.modified("as")||t.modified("filter")?(a&&(r.rem=a),a=n.materialize(n.SOURCE).source,r.add=this.value=function(t,e,n,r){for(var a,s,u=[],o={},l=t.length,f=0;f<l;++f)for(o[e]=s=t[f],a=0;a<l;++a)o[n]=t[a],r(o)&&(u.push(i.ingest(o)),(o={})[e]=s);return u}(a,u,o,t.filter||e.truthy)):r.mod=a,r.source=this.value,r.modifies(s)};var q={kde:n.randomKDE,mixture:n.randomMixture,normal:n.randomNormal,uniform:n.randomUniform},w="distributions",T="function",N="field";function R(t){i.Transform.call(this,null,t)}var M=[{key:{function:"normal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"uniform"},params:[{name:"min",type:"number",default:0},{name:"max",type:"number",default:1}]},{key:{function:"kde"},params:[{name:"field",type:"field",required:!0},{name:"from",type:"data"},{name:"bandwidth",type:"number",default:0}]}],S={key:{function:"mixture"},params:[{name:"distributions",type:"param",array:!0,params:M},{name:"weights",type:"number",array:!0}]};function C(t){i.Operator.call(this,null,A,t),this.modified(!0)}function A(t){var i=t.expr;return this.value&&!t.modified("expr")?this.value:e.accessor(function(e){return i(e,t)},e.accessorFields(i),e.accessorName(i))}function U(t){i.Transform.call(this,[void 0,void 0],t)}function F(t,e){i.Operator.call(this,t),this.parent=e}R.Definition={type:"Density",metadata:{generates:!0},params:[{name:"extent",type:"number",array:!0,length:2},{name:"steps",type:"number",default:100},{name:"method",type:"string",default:"pdf",values:["pdf","cdf"]},{name:"distribution",type:"param",params:M.concat(S)},{name:"as",type:"string",array:!0,default:["value","density"]}]},e.inherits(R,i.Transform).transform=function(t,n){var a=n.fork(n.NO_SOURCE|n.NO_FIELDS);if(!this.value||n.changed()||t.modified()){var s=function t(i,n){var r=i[T];q.hasOwnProperty(r)||e.error("Unknown distribution function: "+r);var a=q[r]();for(var s in i)s===N?a.data((i.from||n()).map(i[s])):s===w?a[s](i[s].map(function(e){return t(e,n)})):typeof a[s]===T&&a[s](i[s]);return a}(t.distribution,function(t){return function(){return t.materialize(t.SOURCE).source}}(n)),u=t.method||"pdf";"pdf"!==u&&"cdf"!==u&&e.error("Invalid density method: "+u),t.extent||s.data||e.error("Missing density extent parameter."),u=s[u];var o=t.as||["value","density"],l=t.extent||r.extent(s.data()),f=(l[1]-l[0])/(t.steps||100),d=r.range(l[0],l[1]+f/2,f).map(function(t){var e={};return e[o[0]]=t,e[o[1]]=u(t),i.ingest(e)});this.value&&(a.rem=this.value),this.value=a.add=a.source=d}return a},e.inherits(C,i.Operator),U.Definition={type:"Extent",metadata:{},params:[{name:"field",type:"field",required:!0}]},e.inherits(U,i.Transform).transform=function(t,e){var i,n=this.value,r=t.field,a=n[0],s=n[1];((i=e.changed()||e.modified(r.fields)||t.modified("field"))||null==a)&&(a=1/0,s=-1/0),e.visit(i?e.SOURCE:e.ADD,function(t){var e=r(t);null!=e&&((e=+e)<a&&(a=e),e>s&&(s=e))}),isFinite(a)&&isFinite(s)||(a=s=void 0),this.value=[a,s]};var z=e.inherits(F,i.Operator);function L(t){i.Transform.call(this,{},t),this._keys=e.fastmap();var n=this._targets=[];n.active=0,n.forEach=function(t){for(var e=0,i=n.active;e<i;++e)t(n[e],e,n)}}z.connect=function(t){return this.targets().add(t),t.source=this},z.add=function(t){this.value.add.push(t)},z.rem=function(t){this.value.rem.push(t)},z.mod=function(t){this.value.mod.push(t)},z.init=function(t){this.value.init(t,t.NO_SOURCE)},z.evaluate=function(){return this.value};var P=e.inherits(L,i.Transform);function I(t){i.Operator.call(this,null,j,t)}function j(t){return this.value&&!t.modified()?this.value:e.isArray(t.name)?e.array(t.name).map(function(t){return e.field(t)}):e.field(t.name,t.as)}function W(t){i.Transform.call(this,e.fastmap(),t)}function B(t,i){return t?t.map(function(t,n){return i[n]||e.accessorName(t)}):null}function J(t){i.Transform.call(this,[],t)}function K(t){i.Transform.call(this,[],t)}function $(t){i.Transform.call(this,null,t)}function G(t){i.Transform.call(this,[],t)}P.activate=function(t){this._targets[this._targets.active++]=t},P.subflow=function(t,e,i,n){var r,a,s=this.value,u=s.hasOwnProperty(t)&&s[t];return u?u.value.stamp<i.stamp&&(u.init(i),this.activate(u)):(a=n||(a=this._group[t])&&a.tuple,u=(r=i.dataflow).add(new F(i.fork(i.NO_SOURCE),this)).connect(e(r,t,a)),s[t]=u,this.activate(u)),u},P.transform=function(t,e){var n=e.dataflow,r=this,a=t.key,s=t.subflow,u=this._keys,o=t.modified("key");function l(t){return r.subflow(t,s,e)}return this._group=t.group||{},this._targets.active=0,e.visit(e.REM,function(t){var e=i.tupleid(t),n=u.get(e);void 0!==n&&(u.delete(e),l(n).rem(t))}),e.visit(e.ADD,function(t){var e=a(t);u.set(i.tupleid(t),e),l(e).add(t)}),o||e.modified(a.fields)?e.visit(e.MOD,function(t){var e=i.tupleid(t),n=u.get(e),r=a(t);n===r?l(r).mod(t):(u.set(e,r),l(n).rem(t),l(r).add(t))}):e.changed(e.MOD)&&e.visit(e.MOD,function(t){l(u.get(i.tupleid(t))).mod(t)}),o&&e.visit(e.REFLOW,function(t){var e=i.tupleid(t),n=u.get(e),r=a(t);n!==r&&(u.set(e,r),l(n).rem(t),l(r).add(t))}),u.empty>n.cleanThreshold&&n.runAfter(u.clean),e},e.inherits(I,i.Operator),W.Definition={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]},e.inherits(W,i.Transform).transform=function(t,e){var n=e.dataflow,r=this.value,a=e.fork(),s=a.add,u=a.rem,o=a.mod,l=t.expr,f=!0;function d(e){var n=i.tupleid(e),a=l(e,t),d=r.get(n);a&&d?(r.delete(n),s.push(e)):a||d?f&&a&&!d&&o.push(e):(r.set(n,1),u.push(e))}return e.visit(e.REM,function(t){var e=i.tupleid(t);r.has(e)?r.delete(e):u.push(t)}),e.visit(e.ADD,function(e){l(e,t)?s.push(e):r.set(i.tupleid(e),1)}),e.visit(e.MOD,d),t.modified()&&(f=!1,e.visit(e.REFLOW,d)),r.empty>n.cleanThreshold&&n.runAfter(r.clean),a},J.Definition={type:"Flatten",metadata:{generates:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0}]},e.inherits(J,i.Transform).transform=function(t,e){var n=e.fork(e.NO_SOURCE),r=t.fields,a=B(r,t.as||[]),s=a.length;return n.rem=this.value,e.visit(e.SOURCE,function(t){for(var e,u,o,l=r.map(function(e){return e(t)}),f=l.reduce(function(t,e){return Math.max(t,e.length)},0),d=0;d<f;++d){for(u=i.derive(t),e=0;e<s;++e)u[a[e]]=null==(o=l[e][d])?null:o;n.add.push(u)}}),this.value=n.source=n.add,n.modifies(a)},K.Definition={type:"Fold",metadata:{generates:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0,length:2,default:["key","value"]}]},e.inherits(K,i.Transform).transform=function(t,n){var r=n.fork(n.NO_SOURCE),a=t.fields,s=a.map(e.accessorName),u=t.as||["key","value"],o=u[0],l=u[1],f=a.length;return r.rem=this.value,n.visit(n.SOURCE,function(t){for(var e,n=0;n<f;++n)(e=i.derive(t))[o]=s[n],e[l]=a[n](t),r.add.push(e)}),this.value=r.source=r.add,r.modifies(u)},$.Definition={type:"Formula",metadata:{modifies:!0},params:[{name:"expr",type:"expr",required:!0},{name:"as",type:"string",required:!0},{name:"initonly",type:"boolean"}]},e.inherits($,i.Transform).transform=function(t,e){var i=t.expr,n=t.as,r=t.modified(),a=t.initonly?e.ADD:r?e.SOURCE:e.modified(i.fields)?e.ADD_MOD:e.ADD;return r&&(e=e.materialize().reflow(!0)),t.initonly||e.modifies(n),e.visit(a,function(e){e[n]=i(e,t)})},e.inherits(G,i.Transform).transform=function(t,e){var n,r,a,s=this.value,u=e.fork(e.ALL),o=t.size-s.length,l=t.generator;if(o>0){for(n=[];--o>=0;)n.push(a=i.ingest(l(t))),s.push(a);u.add=u.add.length?u.materialize(u.ADD).add.concat(n):n}else r=s.slice(0,-o),u.rem=u.rem.length?u.materialize(u.REM).rem.concat(r):r,s=s.slice(-o);return u.source=this.value=s,u};var H={value:"value",median:r.median,mean:r.mean,min:r.min,max:r.max},Q=[];function V(t){i.Transform.call(this,[],t)}function X(t){p.call(this,t)}V.Definition={type:"Impute",metadata:{changes:!0},params:[{name:"field",type:"field",required:!0},{name:"key",type:"field",required:!0},{name:"keyvals",array:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"enum",default:"value",values:["value","mean","median","max","min"]},{name:"value",default:0}]},e.inherits(V,i.Transform).transform=function(t,n){var r,a,s,u,o,l,f,d,m,c,h=n.fork(n.ALL),p=function(t){var i,n=t.method||H.value;if(null!=H[n])return n===H.value?(i=void 0!==t.value?t.value:0,function(){return i}):H[n];e.error("Unrecognized imputation method: "+n)}(t),v=function(t){var e=t.field;return function(t){return t?e(t):NaN}}(t),g=e.accessorName(t.field),y=e.accessorName(t.key),_=(t.groupby||[]).map(e.accessorName),x=function(t,e,i,n){var r,a,s,u,o,l,f,d,m=function(t){return t(d)},c=[],h=n?n.slice():[],p={},v={};for(h.forEach(function(t,e){p[t]=e+1}),u=0,f=t.length;u<f;++u)d=t[u],l=i(d),o=p[l]||(p[l]=h.push(l)),a=(r=e?e.map(m):Q)+"",(s=v[a])||(s=v[a]=[],c.push(s),s.values=r),s[o-1]=d;return c.domain=h,c}(n.source,t.groupby,t.key,t.keyvals),O=[],D=this.value,b=x.domain.length;for(o=0,d=x.length;o<d;++o)for(s=(r=x[o]).values,a=NaN,f=0;f<b;++f)if(null==r[f]){for(u=x.domain[f],c={_impute:!0},l=0,m=s.length;l<m;++l)c[_[l]]=s[l];c[y]=u,c[g]=isNaN(a)?a=p(r,v):a,O.push(i.ingest(c))}return O.length&&(h.add=h.materialize(h.ADD).add.concat(O)),D.length&&(h.rem=h.materialize(h.REM).rem.concat(D)),this.value=O,h},X.Definition={type:"JoinAggregate",metadata:{modifies:!0},params:[{name:"groupby",type:"field",array:!0},{name:"fields",type:"field",null:!0,array:!0},{name:"ops",type:"enum",array:!0,values:o},{name:"as",type:"string",null:!0,array:!0},{name:"key",type:"field"}]};var Y=e.inherits(X,p);function Z(t){i.Operator.call(this,null,tt,t)}function tt(t){return this.value&&!t.modified()?this.value:e.key(t.fields,t.flat)}function et(t){i.Transform.call(this,[],t)}function it(t,e,n){n.forEach(i.ingest);const r=e.fork(e.NO_FIELDS&e.NO_SOURCE);return r.rem=t.value,t.value=r.add=r.source=n,r}function nt(t){i.Transform.call(this,{},t)}function rt(t){i.Operator.call(this,null,at,t)}function at(t){if(this.value&&!t.modified())return this.value;var e,i,n,r=1/0,a=-1/0,s=t.extents;for(e=0,i=s.length;e<i;++e)(n=s[e])[0]<r&&(r=n[0]),n[1]>a&&(a=n[1]);return[r,a]}function st(t){i.Operator.call(this,null,ut,t)}function ut(t){return this.value&&!t.modified()?this.value:t.values.reduce(function(t,e){return t.concat(e)},[])}function ot(t){i.Transform.call(this,null,t)}function lt(t){p.call(this,t)}Y.transform=function(t,i){var n,r=this,a=t.modified();return r.value&&(a||i.modified(r._inputs))?(n=r.value=a?r.init(t):{},i.visit(i.SOURCE,function(t){r.add(t)})):(n=r.value=r.value||this.init(t),i.visit(i.REM,function(t){r.rem(t)}),i.visit(i.ADD,function(t){r.add(t)})),r.changes(),i.visit(i.SOURCE,function(t){e.extend(t,n[r.cellkey(t)].tuple)}),i.reflow(a).modifies(this._outputs)},Y.changes=function(){var t,e,i=this._adds,n=this._mods;for(t=0,e=this._alen;t<e;++t)this.celltuple(i[t]),i[t]=null;for(t=0,e=this._mlen;t<e;++t)this.celltuple(n[t]),n[t]=null;this._alen=this._mlen=0},e.inherits(Z,i.Operator),e.inherits(et,i.Transform).transform=function(t,e){const i=e.dataflow;return t.values?it(this,e,i.parse(t.values,t.format)):i.request(t.url,t.format).then(t=>it(this,e,t.data||[]))},nt.Definition={type:"Lookup",metadata:{modifies:!0},params:[{name:"index",type:"index",params:[{name:"from",type:"data",required:!0},{name:"key",type:"field",required:!0}]},{name:"values",type:"field",array:!0},{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0},{name:"default",default:null}]},e.inherits(nt,i.Transform).transform=function(t,i){var n,r,a=i,s=t.as,u=t.fields,o=t.index,l=t.values,f=null==t.default?null:t.default,d=t.modified(),m=d?i.SOURCE:i.ADD,c=u.length;return l?(r=l.length,c>1&&!s&&e.error('Multi-field lookup requires explicit "as" parameter.'),s&&s.length!==c*r&&e.error('The "as" parameter has too few output field names.'),s=s||l.map(e.accessorName),n=function(t){for(var e,i,n=0,a=0;n<c;++n)if(null==(i=o.get(u[n](t))))for(e=0;e<r;++e,++a)t[s[a]]=f;else for(e=0;e<r;++e,++a)t[s[a]]=l[e](i)}):(s||e.error("Missing output field names."),n=function(t){for(var e,i=0;i<c;++i)e=o.get(u[i](t)),t[s[i]]=null==e?f:e}),d?a=i.reflow(!0):m|=u.some(function(t){return i.modified(t.fields)})?i.MOD:0,i.visit(m,n),a.modifies(s)},e.inherits(rt,i.Operator),e.inherits(st,i.Operator),e.inherits(ot,i.Transform),ot.prototype.transform=function(t,e){return this.modified(t.modified()),this.value=t,e.fork(e.NO_SOURCE|e.NO_FIELDS)},lt.Definition={type:"Pivot",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"field",type:"field",required:!0},{name:"value",type:"field",required:!0},{name:"op",type:"enum",values:o,default:"sum"},{name:"limit",type:"number",default:0},{name:"key",type:"field"}]};var ft=e.inherits(lt,p);function dt(t){L.call(this,t)}function mt(t){i.Transform.call(this,null,t)}function ct(t){i.Transform.call(this,null,t)}function ht(t){i.Transform.call(this,null,t)}function pt(t){i.Transform.call(this,[],t),this.count=0}function vt(t){i.Transform.call(this,null,t)}function gt(t){i.Transform.call(this,null,t),this.modified(!0)}function yt(t){i.Transform.call(this,e.fastmap(),t)}function _t(t){i.Transform.call(this,null,t)}ft._transform=ft.transform,ft.transform=function(t,i){return this._transform(function(t,i){var n=t.field,r=t.value,a=("count"===t.op?"__count__":t.op)||"sum",s=e.accessorFields(n).concat(e.accessorFields(r)),u=function(t,e,i){var n={},r=[];return i.visit(i.SOURCE,function(e){var i=t(e);n[i]||(n[i]=1,r.push(i))}),r.sort(function(t,e){return(t<e||null==t)&&null!=e?-1:(t>e||null==e)&&null!=t?1:(e=e instanceof Date?+e:e,(t=t instanceof Date?+t:t)!==t&&e==e?-1:e!=e&&t==t?1:0)}),e?r.slice(0,e):r}(n,t.limit||0,i);return{key:t.key,groupby:t.groupby,ops:u.map(function(){return a}),fields:u.map(function(t){return function(t,i,n,r){return e.accessor(function(e){return i(e)===t?n(e):NaN},r,t+"")}(t,n,r,s)}),as:u.map(function(t){return t+""}),modified:t.modified.bind(t)}}(t,i),i)},e.inherits(dt,L).transform=function(t,n){var r=this,a=t.subflow,s=t.field;return(t.modified("field")||s&&n.modified(e.accessorFields(s)))&&e.error("PreFacet does not support field modification."),this._targets.active=0,n.visit(n.MOD,function(t){var e=r.subflow(i.tupleid(t),a,n,t);s?s(t).forEach(function(t){e.mod(t)}):e.mod(t)}),n.visit(n.ADD,function(t){var e=r.subflow(i.tupleid(t),a,n,t);s?s(t).forEach(function(t){e.add(i.ingest(t))}):e.add(t)}),n.visit(n.REM,function(t){var e=r.subflow(i.tupleid(t),a,n,t);s?s(t).forEach(function(t){e.rem(t)}):e.rem(t)}),n},mt.Definition={type:"Project",metadata:{generates:!0,changes:!0},params:[{name:"fields",type:"field",array:!0},{name:"as",type:"string",null:!0,array:!0}]},e.inherits(mt,i.Transform).transform=function(t,e){var n,r,a=t.fields,s=B(t.fields,t.as||[]),u=a?function(t,e){return function(t,e,i,n){for(var r=0,a=i.length;r<a;++r)e[n[r]]=i[r](t);return e}(t,e,a,s)}:i.rederive;return this.value?r=this.value:(e=e.addAll(),r=this.value={}),n=e.fork(e.NO_SOURCE),e.visit(e.REM,function(t){var e=i.tupleid(t);n.rem.push(r[e]),r[e]=null}),e.visit(e.ADD,function(t){var e=u(t,i.ingest({}));r[i.tupleid(t)]=e,n.add.push(e)}),e.visit(e.MOD,function(t){n.mod.push(u(t,r[i.tupleid(t)]))}),n},e.inherits(ct,i.Transform).transform=function(t,e){return this.value=t.value,t.modified("value")?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation},e.inherits(ht,i.Transform).transform=function(t,e){var n,r;return this.value?r=this.value:(n=e=e.addAll(),r=this.value={}),t.derive&&(n=e.fork(e.NO_SOURCE),e.visit(e.REM,function(t){var e=i.tupleid(t);n.rem.push(r[e]),r[e]=null}),e.visit(e.ADD,function(t){var e=i.derive(t);r[i.tupleid(t)]=e,n.add.push(e)}),e.visit(e.MOD,function(t){n.mod.push(i.rederive(t,r[i.tupleid(t)]))})),n},pt.Definition={type:"Sample",metadata:{},params:[{name:"size",type:"number",default:1e3}]},e.inherits(pt,i.Transform).transform=function(t,e){var r=e.fork(e.NO_SOURCE),a=t.modified("size"),s=t.size,u=this.value,o=this.count,l=0,f=u.reduce(function(t,e){return t[i.tupleid(e)]=1,t},{});function d(t){var e,a;u.length<s?u.push(t):(a=~~((o+1)*n.random()))<u.length&&a>=l&&(e=u[a],f[i.tupleid(e)]&&r.rem.push(e),u[a]=t),++o}if(e.rem.length&&(e.visit(e.REM,function(t){var e=i.tupleid(t);f[e]&&(f[e]=-1,r.rem.push(t)),--o}),u=u.filter(function(t){return-1!==f[i.tupleid(t)]})),(e.rem.length||a)&&u.length<s&&e.source&&(l=o=u.length,e.visit(e.SOURCE,function(t){f[i.tupleid(t)]||d(t)}),l=-1),a&&u.length>s){for(var m=0,c=u.length-s;m<c;++m)f[i.tupleid(u[m])]=-1,r.rem.push(u[m]);u=u.slice(c)}return e.mod.length&&e.visit(e.MOD,function(t){f[i.tupleid(t)]&&r.mod.push(t)}),e.add.length&&e.visit(e.ADD,d),(e.add.length||l<0)&&(r.add=u.filter(function(t){return!f[i.tupleid(t)]})),this.count=o,this.value=r.source=u,r},vt.Definition={type:"Sequence",metadata:{changes:!0},params:[{name:"start",type:"number",required:!0},{name:"stop",type:"number",required:!0},{name:"step",type:"number",default:1},{name:"as",type:"string",default:"data"}]},e.inherits(vt,i.Transform).transform=function(t,e){if(!this.value||t.modified()){var n=e.materialize().fork(e.MOD),a=t.as||"data";return n.rem=this.value?e.rem.concat(this.value):e.rem,this.value=r.range(t.start,t.stop,t.step||1).map(function(t){var e={};return e[a]=t,i.ingest(e)}),n.add=e.add.concat(this.value),n}},e.inherits(gt,i.Transform).transform=function(t,e){return this.value=e.source,e.changed()?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation},e.inherits(yt,i.Transform).transform=function(t,e){var i=e.dataflow,n=t.field,r=this.value,a=!0;function s(t){r.set(n(t),t)}return t.modified("field")||e.modified(n.fields)?(r.clear(),e.visit(e.SOURCE,s)):e.changed()?(e.visit(e.REM,function(t){r.delete(n(t))}),e.visit(e.ADD,s)):a=!1,this.modified(a),r.empty>i.cleanThreshold&&i.runAfter(r.clean),e.fork()},e.inherits(_t,i.Transform).transform=function(t,e){(!this.value||t.modified("field")||t.modified("sort")||e.changed()||t.sort&&e.modified(t.sort.fields))&&(this.value=(t.sort?e.source.slice().sort(t.sort):e.source).map(t.field))};var xt={row_number:function(){return{next:function(t){return t.index+1}}},rank:function(){var t;return{init:function(){t=1},next:function(e){var i=e.index,n=e.data;return i&&e.compare(n[i-1],n[i])?t=i+1:t}}},dense_rank:function(){var t;return{init:function(){t=1},next:function(e){var i=e.index,n=e.data;return i&&e.compare(n[i-1],n[i])?++t:t}}},percent_rank:function(){var t=xt.rank(),e=t.next;return{init:t.init,next:function(t){return(e(t)-1)/(t.data.length-1)}}},cume_dist:function(){var t;return{init:function(){t=0},next:function(e){var i=e.index,n=e.data,r=e.compare;if(t<i){for(;i+1<n.length&&!r(n[i],n[i+1]);)++i;t=i}return(1+t)/n.length}}},ntile:function(t,i){(i=+i)>0||e.error("ntile num must be greater than zero.");var n=xt.cume_dist(),r=n.next;return{init:n.init,next:function(t){return Math.ceil(i*r(t))}}},lag:function(t,e){return e=+e||1,{next:function(i){var n=i.index-e;return n>=0?t(i.data[n]):null}}},lead:function(t,e){return e=+e||1,{next:function(i){var n=i.index+e,r=i.data;return n<r.length?t(r[n]):null}}},first_value:function(t){return{next:function(e){return t(e.data[e.i0])}}},last_value:function(t){return{next:function(e){return t(e.data[e.i1-1])}}},nth_value:function(t,i){return(i=+i)>0||e.error("nth_value nth must be greater than zero."),{next:function(e){var n=e.i0+(i-1);return n<e.i1?t(e.data[n]):null}}}},Ot=Object.keys(xt);function Dt(t){var i=e.array(t.ops),n=e.array(t.fields),r=e.array(t.params),a=e.array(t.as),u=this.outputs=[],o=this.windows=[],f={},d={},h=!0,p=[],v=[];function g(t){e.array(e.accessorFields(t)).forEach(function(t){f[t]=1})}g(t.sort),i.forEach(function(t,i){var f=n[i],m=e.accessorName(f),c=s(t,m,a[i]);if(g(f),u.push(c),xt.hasOwnProperty(t))o.push(function(t,i,n,r){var a=xt[t](i,n);return{init:a.init||e.zero,update:function(t,e){e[r]=a.next(t)}}}(t,n[i],r[i],c));else{if(null==f&&"count"!==t&&e.error("Null aggregate field specified."),"count"===t)return void p.push(c);h=!1;var y=d[m];y||((y=d[m]=[]).field=f,v.push(y)),y.push(l(t,c))}}),(p.length||v.length)&&(this.cell=function(t,e,i){t=t.map(function(t){return m(t,t.field)});var n={num:0,agg:null,store:!1,count:e};if(!i)for(var r=t.length,a=n.agg=Array(r),s=0;s<r;++s)a[s]=new t[s](n);if(n.store)var u=n.data=new c;return n.add=function(t){if(n.num+=1,!i){u&&u.add(t);for(var e=0;e<r;++e)a[e].add(a[e].get(t),t)}},n.rem=function(t){if(n.num-=1,!i){u&&u.rem(t);for(var e=0;e<r;++e)a[e].rem(a[e].get(t),t)}},n.set=function(t){var r,s;for(u&&u.values(),r=0,s=e.length;r<s;++r)t[e[r]]=n.num;if(!i)for(r=0,s=a.length;r<s;++r)a[r].set(t)},n.init=function(){n.num=0,u&&u.reset();for(var t=0;t<r;++t)a[t].init()},n}(v,p,h)),this.inputs=Object.keys(f)}var bt=Dt.prototype;function Et(t){i.Transform.call(this,{},t),this._mlen=0,this._mods=[]}bt.init=function(){this.windows.forEach(function(t){t.init()}),this.cell&&this.cell.init()},bt.update=function(t,e){var i,n=this.cell,r=this.windows,a=t.data,s=r&&r.length;if(n){for(i=t.p0;i<t.i0;++i)n.rem(a[i]);for(i=t.p1;i<t.i1;++i)n.add(a[i]);n.set(e)}for(i=0;i<s;++i)r[i].update(t,e)},Et.Definition={type:"Window",metadata:{modifies:!0},params:[{name:"sort",type:"compare"},{name:"groupby",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:Ot.concat(o)},{name:"params",type:"number",null:!0,array:!0},{name:"fields",type:"field",null:!0,array:!0},{name:"as",type:"string",null:!0,array:!0},{name:"frame",type:"number",null:!0,array:!0,length:2,default:[null,0]},{name:"ignorePeers",type:"boolean",default:!1}]};var kt=e.inherits(Et,i.Transform);function qt(t,i,n){var a=n.sort,s=a&&!n.ignorePeers,u=n.frame||[null,0],o=t.data(a),l=o.length,f=0,d=s?r.bisector(a):null,m={i0:0,i1:0,p0:0,p1:0,index:0,data:o,compare:a||e.constant(-1)};for(i.init();f<l;++f)wt(m,u,f,l),s&&Tt(m,d),i.update(m,o[f])}function wt(t,e,i,n){t.p0=t.i0,t.p1=t.i1,t.i0=null==e[0]?0:Math.max(0,i-Math.abs(e[0])),t.i1=null==e[1]?n:Math.min(n,i+Math.abs(e[1])+1),t.index=i}function Tt(t,e){var i=t.i0,n=t.i1-1,r=t.compare,a=t.data,s=a.length-1;i>0&&!r(a[i],a[i-1])&&(t.i0=e.left(a,a[i])),n<s&&!r(a[n],a[n+1])&&(t.i1=e.right(a,a[n]))}kt.transform=function(t,e){var i,n,r=this,s=r.state,u=t.modified();this.stamp=e.stamp,s&&!u||(s=r.state=new Dt(t));var o=a(t.groupby);function l(t){return r.group(o(t))}for(u||e.modified(s.inputs)?(r.value={},e.visit(e.SOURCE,function(t){l(t).add(t)})):(e.visit(e.REM,function(t){l(t).remove(t)}),e.visit(e.ADD,function(t){l(t).add(t)})),i=0,n=r._mlen;i<n;++i)qt(r._mods[i],s,t);return r._mlen=0,r._mods=[],e.reflow(u).modifies(s.outputs)},kt.group=function(t){var e=this.value[t];return e||((e=this.value[t]=_(i.tupleid)).stamp=-1),e.stamp<this.stamp&&(e.stamp=this.stamp,this._mods[this._mlen++]=e),e},t.aggregate=p,t.bin=g,t.collect=x,t.compare=O,t.countpattern=b,t.cross=k,t.density=R,t.expression=C,t.extent=U,t.facet=L,t.field=I,t.filter=W,t.flatten=J,t.fold=K,t.formula=$,t.generate=G,t.impute=V,t.joinaggregate=X,t.key=Z,t.load=et,t.lookup=nt,t.multiextent=rt,t.multivalues=st,t.params=ot,t.pivot=lt,t.prefacet=dt,t.project=mt,t.proxy=ct,t.relay=ht,t.sample=pt,t.sequence=vt,t.sieve=gt,t.subflow=F,t.tupleindex=yt,t.values=_t,t.window=Et,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "vega-transforms",
"version": "2.3.1",
"version": "4.0.0",
"description": "Data processing transforms for Vega dataflows.",

@@ -18,32 +18,22 @@ "keywords": [

"license": "BSD-3-Clause",
"author": {
"name": "Jeffrey Heer",
"url": "http://idl.cs.washington.edu"
},
"author": "Jeffrey Heer (http://idl.cs.washington.edu)",
"main": "build/vega-transforms.js",
"module": "index",
"jsnext:main": "index",
"repository": {
"type": "git",
"url": "https://github.com/vega/vega-transforms.git"
},
"repository": "vega/vega",
"scripts": {
"build": "npm run test && uglifyjs build/vega-transforms.js -c -m -o build/vega-transforms.min.js",
"pretest": "rm -rf build && mkdir build && rollup -g d3-array:d3,vega-dataflow:vega,vega-statistics:vega,vega-util:vega -f umd -n vega.transforms -o build/vega-transforms.js -- index.js",
"rollup": "rollup -g d3-array:d3,vega-dataflow:vega,vega-statistics:vega,vega-util:vega -f umd -n vega.transforms -o build/vega-transforms.js -- index.js",
"prebuild": "rimraf build && mkdir build",
"build": "yarn rollup",
"postbuild": "terser build/vega-transforms.js -c -m -o build/vega-transforms.min.js",
"pretest": "yarn prebuild && yarn rollup",
"test": "tape 'test/**/*-test.js' && eslint index.js src test",
"prepublishOnly": "npm run build",
"postpublish": "git push && git push --tags && zip -j build/vega-transforms.zip -- LICENSE README.md build/vega-transforms.js build/vega-transforms.min.js"
"prepublishOnly": "yarn test && yarn build",
"postpublish": "git push && git push --tags"
},
"dependencies": {
"d3-array": "^2.0.2",
"vega-dataflow": "^4.1.0",
"vega-statistics": "^1.2.3",
"vega-util": "^1.7.0"
},
"devDependencies": {
"eslint": "5",
"rollup": "0.67.4",
"tape": "4",
"uglify-js": "3"
"d3-array": "^2.0.3",
"vega-dataflow": "^5.0.0",
"vega-statistics": "^1.2.4",
"vega-util": "^1.8.0"
}
}

@@ -5,44 +5,43 @@ # vega-transforms

This module provides the following Vega data transforms:
This package provides the following Vega data transforms:
- [**Aggregate**](https://vega.github.io/vega/docs/transforms/aggregate/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Aggregate.js "Source")
- [**Bin**](https://vega.github.io/vega/docs/transforms/bin/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Bin.js "Source")
- [**Collect**](https://vega.github.io/vega/docs/transforms/collect/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Collect.js "Source")
- [**CountPattern**](https://vega.github.io/vega/docs/transforms/countpattern/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/CountPattern.js "Source")
- [**Cross**](https://vega.github.io/vega/docs/transforms/cross/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Cross.js "Source")
- [**Density**](https://vega.github.io/vega/docs/transforms/density/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Density.js "Source")
- [**Extent**](https://vega.github.io/vega/docs/transforms/extent/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Extent.js "Source")
- [**Filter**](https://vega.github.io/vega/docs/transforms/filter/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Filter.js "Source")
- [**Flatten**](https://vega.github.io/vega/docs/transforms/flatten/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Flatten.js "Source")
- [**Fold**](https://vega.github.io/vega/docs/transforms/fold/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Fold.js "Source")
- [**Formula**](https://vega.github.io/vega/docs/transforms/formula/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Formula.js "Source")
- [**Impute**](https://vega.github.io/vega/docs/transforms/Impute/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/impute.js "Source")
- [**JoinAggregate**](https://vega.github.io/vega/docs/transforms/joinaggregate/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/JoinAggregate.js "Source")
- [**Lookup**](https://vega.github.io/vega/docs/transforms/lookup/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Lookup.js "Source")
- [**Pivot**](https://vega.github.io/vega/docs/transforms/pivot/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Pivot.js "Source")
- [**Project**](https://vega.github.io/vega/docs/transforms/project/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Project.js "Source")
- [**Sample**](https://vega.github.io/vega/docs/transforms/sample/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Sample.js "Source")
- [**Sequence**](https://vega.github.io/vega/docs/transforms/sequence/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Sequence.js "Source")
- [**Window**](https://vega.github.io/vega/docs/transforms/window/) [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Window.js "Source")
- [**Aggregate**](https://vega.github.io/vega/docs/transforms/aggregate/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Aggregate.js "Source")
- [**Bin**](https://vega.github.io/vega/docs/transforms/bin/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Bin.js "Source")
- [**Collect**](https://vega.github.io/vega/docs/transforms/collect/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Collect.js "Source")
- [**CountPattern**](https://vega.github.io/vega/docs/transforms/countpattern/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/CountPattern.js "Source")
- [**Cross**](https://vega.github.io/vega/docs/transforms/cross/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Cross.js "Source")
- [**Density**](https://vega.github.io/vega/docs/transforms/density/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Density.js "Source")
- [**Extent**](https://vega.github.io/vega/docs/transforms/extent/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Extent.js "Source")
- [**Filter**](https://vega.github.io/vega/docs/transforms/filter/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Filter.js "Source")
- [**Flatten**](https://vega.github.io/vega/docs/transforms/flatten/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Flatten.js "Source")
- [**Fold**](https://vega.github.io/vega/docs/transforms/fold/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Fold.js "Source")
- [**Formula**](https://vega.github.io/vega/docs/transforms/formula/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Formula.js "Source")
- [**Impute**](https://vega.github.io/vega/docs/transforms/Impute/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/impute.js "Source")
- [**JoinAggregate**](https://vega.github.io/vega/docs/transforms/joinaggregate/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/JoinAggregate.js "Source")
- [**Lookup**](https://vega.github.io/vega/docs/transforms/lookup/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Lookup.js "Source")
- [**Pivot**](https://vega.github.io/vega/docs/transforms/pivot/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Pivot.js "Source")
- [**Project**](https://vega.github.io/vega/docs/transforms/project/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Project.js "Source")
- [**Sample**](https://vega.github.io/vega/docs/transforms/sample/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Sample.js "Source")
- [**Sequence**](https://vega.github.io/vega/docs/transforms/sequence/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Sequence.js "Source")
- [**Window**](https://vega.github.io/vega/docs/transforms/window/) [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Window.js "Source")
And also provides the following internal transforms:
And provides the following internal transforms:
- **Compare** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Compare.js "Source")
- **Expression** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Expression.js "Source")
- **Facet** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Facet.js "Source")
- **Field** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Field.js "Source")
- **Generate** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Generate.js "Source")
- **Key** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Key.js "Source")
- **MultiExtent** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/MultiExtent.js "Source")
- **MultiValues** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/MultiValues.js "Source")
- **Params** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Params.js "Source")
- **PreFacet** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/PreFacet.js "Source")
- **Proxy** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Proxy.js "Source")
- **Relay** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Relay.js "Source")
- **Sieve** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Sieve.js "Source")
- **Subflow** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Subflow.js "Source")
- **TupleIndex** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/TupleIndex.js "Source")
- **Values** [&lt;&gt;](https://github.com/vega/vega-transforms/blob/master/src/Values.js "Source")
- **Compare** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Compare.js "Source")
- **Expression** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Expression.js "Source")
- **Facet** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Facet.js "Source")
- **Field** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Field.js "Source")
- **Generate** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Generate.js "Source")
- **Key** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Key.js "Source")
- **MultiExtent** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/MultiExtent.js "Source")
- **MultiValues** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/MultiValues.js "Source")
- **Params** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Params.js "Source")
- **PreFacet** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/PreFacet.js "Source")
- **Proxy** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Proxy.js "Source")
- **Relay** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Relay.js "Source")
- **Sieve** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Sieve.js "Source")
- **Subflow** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Subflow.js "Source")
- **TupleIndex** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/TupleIndex.js "Source")
- **Values** [&lt;&gt;](https://github.com/vega/vega/blob/master/packages/vega-transforms/src/Values.js "Source")
For more information about data stream transforms, see the
[Vega transform documentation](https://vega.github.io/vega/docs/transforms/).
For more information about data stream transforms, see the [Vega transform documentation](https://vega.github.io/vega/docs/transforms/).

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

import {Transform} from 'vega-dataflow';
import {ingest, Transform} from 'vega-dataflow';
import {inherits} from 'vega-util';

@@ -13,3 +13,3 @@

export default function Load(params) {
Transform.call(this, null, params);
Transform.call(this, [], params);
}

@@ -20,3 +20,20 @@

prototype.transform = function(_, pulse) {
pulse.dataflow.request(this.target, _.url, _.format);
const df = pulse.dataflow;
if (_.values) {
// parse and ingest values
return output(this, pulse, df.parse(_.values, _.format));
} else {
// return promise for async loading
return df.request(_.url, _.format)
.then(res => output(this, pulse, res.data || []));
}
};
function output(op, pulse, data) {
data.forEach(ingest);
const out = pulse.fork(pulse.NO_FIELDS & pulse.NO_SOURCE);
out.rem = op.value;
op.value = out.add = out.source = data;
return out;
}

Sorry, the diff of this file is too big to display

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