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.2.0 to 2.3.0

2

build/vega-transforms.min.js

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

!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.vega=t.vega||{},t.vega.transforms={}),t.vega,t.vega,t.vega,t.d3)}(this,function(t,b,E,m,d){"use strict";function v(t){return t&&t.length?1===t.length?t[0]:(r=t,function(t){for(var e=r.length,i=1,n=String(r[0](t));i<e;++i)n+="|"+r[i](t);return n}):function(){return""};var r}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.mean"}),average:i({name:"average",set:"this.mean",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) : 0",req:["mean"],idx:1}),variancep:i({name:"variancep",set:"this.valid > 1 ? this.dev / this.valid : 0",req:["variance"],idx:2}),stdev:i({name:"stdev",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid-1)) : 0",req:["variance"],idx:2}),stdevp:i({name:"stdevp",set:"this.valid > 1 ? Math.sqrt(this.dev / this.valid) : 0",req:["variance"],idx:2}),stderr:i({name:"stderr",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid * (this.valid-1))) : 0",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 = null;",add:"if (v < this.min) this.argmin = t;",rem:"if (v <= this.min) this.argmin = null;",set:"this.argmin || cell.data.argmin(this.get)",req:["min"],str:["values"],idx:3}),argmax:i({name:"argmax",init:"this.argmax = null;",add:"if (v > this.max) this.argmax = t;",rem:"if (v >= this.max) this.argmax = null;",set:"this.argmax || cell.data.argmax(this.get)",req:["max"],str:["values"],idx:3}),min:i({name:"min",init:"this.min = null;",add:"if (v < this.min || this.min === null) 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 = null;",add:"if (v > this.max || this.max === null) 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=b.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||b.identity,n=function(t,r){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),r&&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),r="var cell = this.cell; this.valid = 0; this.missing = 0;",a="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){r+=t.init,s+=t.add,u+=t.rem}),t.slice().sort(f).forEach(function(t){o+="t['"+t.out+"']="+t.set+";"}),o+="return t;",(a=Function("cell",a)).prototype.init=Function(r),a.prototype.add=Function("v","t",s),a.prototype.rem=Function("v","t",u),a.prototype.set=Function("t",o),a.prototype.get=i,a.fields=t.map(function(t){return t.out}),a}function o(t){this._key=t?b.field(t):E.tupleid,this.reset()}var n=o.prototype;function r(t){E.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,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(e=t=0;t<s;++t)l[a(i=n[t])]?l[a(i)]=0:o[e++]=i;return this._rem=[],this._add=o},n.distinct=function(t){for(var e,i=this.values(),n=i.length,r={},a=0;0<=--n;)e=t(i[n])+"",r.hasOwnProperty(e)||(r[e]=1,++a);return a},n.extent=function(t){if(this._get!==t||!this._ext){var e=this.values(),i=b.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):1/0},n.max=function(t){var e=this.extent(t)[1];return null!=e?t(e):-1/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]},r.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 a=b.inherits(r,E.Transform);function s(t){E.Transform.call(this,null,t)}a.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&&1<n._dims.length&&(n._drop=!1,this.cross()),n.changes(r)},a.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,r;for(e in t)for(n=t[e].tuple,i=0;i<m;++i)d[i][r=n[f[i]]]=r}t(o._prev),t(l),function t(e,i,n){var r,a,s=f[n],u=d[n++];for(r in u)i[s]=u[r],a=e?e+"|"+r:r,n<m?t(a,i,n):l[a]||o.cell(a,i)}("",{},0)},a.init=function(t){var a=this._inputs=[],i=this._outputs=[],s={};function n(t){for(var e,i=b.array(b.accessorFields(t)),n=0,r=i.length;n<r;++n)s[e=i[n]]||(s[e]=1,a.push(e))}this._dims=b.array(t.groupby),this._dnames=this._dims.map(function(t){var e=b.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,r,u,o,l,f,d=t.fields||[null],m=t.ops||["count"],c=t.as||[],h=d.length,p={};for(h!==m.length&&b.error("Unmatched number of fields and aggregate ops."),f=0;f<h;++f)e=d[f],r=m[f],null==e&&"count"!==r&&b.error("Null aggregate field specified."),l=O(r,o=b.accessorName(e),c[f]),i.push(l),"count"!==r?((u=p[o])||(n(e),(u=p[o]=[]).field=e,this._measures.push(u)),"count"!==r&&(this._countOnly=!1),u.push(D(r,l))):this._counts.push(l);return this._measures=this._measures.map(function(t){return k(t,t.field)}),{}},a.cellkey=v(),a.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},a.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 o),i},a.newtuple=function(t,e){var i,n,r=this._dnames,a=this._dims,s={};for(i=0,n=a.length;i<n;++i)s[r[i]]=a[i](t);return e?E.replace(e.tuple,s):E.ingest(s)},a.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)},a.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)},a.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},a.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},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=b.inherits(s,E.Transform);function c(t,e,i){var n=t,r=e||[],a=i||[],s={},u=0;return{add:function(t){a.push(t)},remove:function(t){s[n(t)]=++u},size:function(){return r.length},data:function(t,e){return u&&(r=r.filter(function(t){return!s[n(t)]}),s={},u=0),e&&t&&r.sort(t),a.length&&(r=t?b.merge(t,r,a.sort(t)):r.concat(a),a=[]),r}}}function h(t){E.Transform.call(this,[],t)}function p(t){E.Operator.call(this,null,g,t)}function g(t){return this.value&&!t.modified()?this.value:b.compare(t.fields,t.orders)}function y(t){E.Transform.call(this,null,t)}u.transform=function(t,e){var i,n=this._bins(t),r=n.start,a=n.step,s=t.as||["bin0","bin1"],u=s[0],o=s[1];return i=t.modified()?(e=e.reflow(!0)).SOURCE:e.modified(b.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:r+a*(1+(e-r)/a)}),e.modifies(s)},u._bins=function(t){if(this.value&&!t.modified())return this.value;var e,i,n=t.field,r=m.bin(t),a=r.start,s=r.stop,u=r.step;null!=(e=t.anchor)&&(i=e-(a+u*Math.floor((e-a)/u)),a+=i,s+=i);var o=function(t){var e=n(t);return null==e?null:(e=Math.max(a,Math.min(+e,s-u)),a+u*Math.floor((e-a)/u))};return o.start=a,o.stop=s,o.step=u,this.value=b.accessor(o,b.accessorFields(n),t.name||"bin_"+b.accessorName(n))},h.Definition={type:"Collect",metadata:{source:!0},params:[{name:"sort",type:"compare"}]},b.inherits(h,E.Transform).transform=function(t,e){var i=e.fork(e.ALL),n=c(E.tupleid,this.value,i.materialize(i.ADD).add),r=t.sort,a=e.changed()||r&&(t.modified("sort")||e.modified(r.fields));return i.visit(i.REM,n.remove),this.modified(a),this.value=i.source=n.data(r,a),e.source&&e.source.root&&(this.value.root=e.source.root),i},b.inherits(p,E.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 _=b.inherits(y,E.Transform);function x(t){E.Transform.call(this,null,t)}_.transform=function(s,t){function e(a){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,r=i.length;n<r;++n)o.test(e=i[n])||a(e)}}var i=this._parameterCheck(s,t),n=this._counts,u=this._match,o=this._stop,l=s.field,r=s.as||["text","count"],a=e(function(t){n[t]=1+(n[t]||0)}),f=e(function(t){n[t]-=1});return i?t.visit(t.SOURCE,a):(t.visit(t.ADD,a),t.visit(t.REM,f)),this._finish(t,r)},_._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,r,a=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 a)n=s[i],r=a[i]||0,!n&&r?(s[i]=n=E.ingest({}),n[u]=i,n[o]=r,l.add.push(n)):0===r?(n&&l.rem.push(n),a[i]=null,s[i]=null):n[o]!==r&&(n[o]=r,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"]}]},b.inherits(x,E.Transform).transform=function(t,e){var i=e.fork(e.NO_SOURCE),n=this.value,r=t.as||["a","b"],a=r[0],s=r[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 r,a,s=[],u={},o=t.length,l=0;l<o;++l)for(u[e]=a=t[l],r=0;r<o;++r)u[i]=t[r],n(u)&&(s.push(E.ingest(u)),(u={})[e]=a);return s}(n,a,s,t.filter||b.truthy)):i.mod=n,i.source=this.value,i.modifies(r)};var q={kde:m.randomKDE,mixture:m.randomMixture,normal:m.randomNormal,uniform:m.randomUniform},w="distributions",T="function",N="field";function R(t){E.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){E.Operator.call(this,null,A,t),this.modified(!0)}function A(e){var i=e.expr;return this.value&&!e.modified("expr")?this.value:b.accessor(function(t){return i(t,e)},b.accessorFields(i),b.accessorName(i))}function U(t){E.Transform.call(this,[1/0,-1/0],t)}function F(t,e){E.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"]}]},b.inherits(R,E.Transform).transform=function(t,e){var i,n=e.fork(e.NO_SOURCE|e.NO_FIELDS);if(!this.value||e.changed()||t.modified()){var r=function e(t,i){var n=t[T];q.hasOwnProperty(n)||b.error("Unknown distribution function: "+n);var r=q[n]();for(var a in t)a===N?r.data((t.from||i()).map(t[a])):a===w?r[a](t[a].map(function(t){return e(t,i)})):typeof r[a]===T&&r[a](t[a]);return r}(t.distribution,(i=e,function(){return i.materialize(i.SOURCE).source})),a=t.method||"pdf";"pdf"!==a&&"cdf"!==a&&b.error("Invalid density method: "+a),t.extent||r.data||b.error("Missing density extent parameter."),a=r[a];var s=t.as||["value","density"],u=t.extent||d.extent(r.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]]=a(t),E.ingest(e)});this.value&&(n.rem=this.value),this.value=n.add=n.source=l}return n},b.inherits(C,E.Operator),U.Definition={type:"Extent",metadata:{},params:[{name:"field",type:"field",required:!0}]},b.inherits(U,E.Transform).transform=function(t,e){var i=this.value,n=t.field,r=i[0],a=i[1],s=e.ADD;(e.changed()||e.modified(n.fields)||t.modified("field"))&&(s=e.SOURCE,r=1/0,a=-1/0),e.visit(s,function(t){var e=n(t);null!=e&&((e=+e)<r&&(r=e),a<e&&(a=e))}),this.value=[r,a]};var z=b.inherits(F,E.Operator);function L(t){E.Transform.call(this,{},t),this._keys=b.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=b.inherits(L,E.Transform);function I(t){E.Operator.call(this,null,j,t)}function j(t){return this.value&&!t.modified()?this.value:b.isArray(t.name)?b.array(t.name).map(function(t){return b.field(t)}):b.field(t.name,t.as)}function W(t){E.Transform.call(this,b.fastmap(),t)}function B(t,i){return t?t.map(function(t,e){return i[e]||b.accessorName(t)}):null}function J(t){E.Transform.call(this,[],t)}function K(t){E.Transform.call(this,[],t)}function $(t){E.Transform.call(this,null,t)}function G(t){E.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 i=e.dataflow,n=this,r=t.key,a=t.subflow,s=this._keys,u=t.modified("key");function o(t){return n.subflow(t,a,e)}return this._group=t.group||{},this._targets.active=0,e.visit(e.REM,function(t){var e=E.tupleid(t),i=s.get(e);void 0!==i&&(s.delete(e),o(i).rem(t))}),e.visit(e.ADD,function(t){var e=r(t);s.set(E.tupleid(t),e),o(e).add(t)}),u||e.modified(r.fields)?e.visit(e.MOD,function(t){var e=E.tupleid(t),i=s.get(e),n=r(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(E.tupleid(t))).mod(t)}),u&&e.visit(e.REFLOW,function(t){var e=E.tupleid(t),i=s.get(e),n=r(t);i!==n&&(s.set(e,n),o(i).rem(t),o(n).add(t))}),s.empty>i.cleanThreshold&&i.runAfter(s.clean),e},b.inherits(I,E.Operator),W.Definition={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]},b.inherits(W,E.Transform).transform=function(r,t){var e=t.dataflow,a=this.value,i=t.fork(),s=i.add,u=i.rem,o=i.mod,l=r.expr,f=!0;function n(t){var e=E.tupleid(t),i=l(t,r),n=a.get(e);i&&n?(a.delete(e),s.push(t)):i||n?f&&i&&!n&&o.push(t):(a.set(e,1),u.push(t))}return t.visit(t.REM,function(t){var e=E.tupleid(t);a.has(e)?a.delete(e):u.push(t)}),t.visit(t.ADD,function(t){l(t,r)?s.push(t):a.set(E.tupleid(t),1)}),t.visit(t.MOD,n),r.modified()&&(f=!1,t.visit(t.REFLOW,n)),a.empty>e.cleanThreshold&&e.runAfter(a.clean),i},J.Definition={type:"Flatten",metadata:{generates:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0}]},b.inherits(J,E.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,r=o.map(function(t){return t(e)}),a=r.reduce(function(t,e){return Math.max(t,e.length)},0),s=0;s<a;++s){for(i=E.derive(e),t=0;t<f;++t)i[l[t]]=null==(n=r[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"]}]},b.inherits(K,E.Transform).transform=function(t,e){var n=e.fork(e.NO_SOURCE),r=t.fields,a=r.map(b.accessorName),i=t.as||["key","value"],s=i[0],u=i[1],o=r.length;return n.rem=this.value,e.visit(e.SOURCE,function(t){for(var e,i=0;i<o;++i)(e=E.derive(t))[s]=a[i],e[u]=r[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"}]},b.inherits($,E.Transform).transform=function(e,t){var i=e.expr,n=e.as,r=e.modified(),a=e.initonly?t.ADD:r?t.SOURCE:t.modified(i.fields)?t.ADD_MOD:t.ADD;return r&&(t=t.materialize().reflow(!0)),e.initonly||t.modifies(n),t.visit(a,function(t){t[n]=i(t,e)})},b.inherits(G,E.Transform).transform=function(t,e){var i,n,r,a=this.value,s=e.fork(e.ALL),u=t.size-a.length,o=t.generator;if(0<u){for(i=[];0<=--u;)i.push(r=E.ingest(o(t))),a.push(r);s.add=s.add.length?s.materialize(s.ADD).add.concat(i):i}else n=a.slice(0,-u),s.rem=s.rem.length?s.materialize(s.REM).rem.concat(n):n,a=a.slice(-u);return s.source=this.value=a,s};var H={value:"value",median:d.median,mean:d.mean,min:d.min,max:d.max},Q=[];function V(t){E.Transform.call(this,[],t)}function X(t){r.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}]},b.inherits(V,E.Transform).transform=function(t,e){var i,n,r,a,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];b.error("Unrecognized imputation method: "+i)}(t),p=(m=t.field,function(t){return t?m(t):NaN}),v=b.accessorName(t.field),g=b.accessorName(t.key),y=(t.groupby||[]).map(b.accessorName),_=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}(e.source,t.groupby,t.key,t.keyvals),x=[],O=this.value,D=_.domain.length;for(s=0,l=_.length;s<l;++s)for(r=(i=_[s]).values,n=NaN,o=0;o<D;++o)if(null==i[o]){for(a=_.domain[o],d={_impute:!0},u=0,f=r.length;u<f;++u)d[y[u]]=r[u];d[g]=a,d[v]=isNaN(n)?n=h(i,p):n,x.push(E.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=b.inherits(X,r);function Z(t){E.Operator.call(this,null,tt,t)}function tt(t){return this.value&&!t.modified()?this.value:b.key(t.fields,t.flat)}function et(t){E.Transform.call(this,null,t)}function it(t){E.Transform.call(this,{},t)}function nt(t){E.Operator.call(this,null,rt,t)}function rt(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 at(t){E.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){E.Transform.call(this,null,t)}function ot(t){r.call(this,t)}Y.transform=function(t,e){var i,n=this,r=t.modified();return n.value&&(r||e.modified(n._inputs))?(i=n.value=r?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){b.extend(t,i[n.cellkey(t)].tuple)}),e.reflow(r).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},b.inherits(Z,E.Operator),b.inherits(et,E.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}]},b.inherits(it,E.Transform).transform=function(t,e){var i,a,n=e,s=t.as,u=t.fields,o=t.index,l=t.values,f=null==t.default?null:t.default,r=t.modified(),d=r?e.SOURCE:e.ADD,m=u.length;return l?(a=l.length,1<m&&!s&&b.error('Multi-field lookup requires explicit "as" parameter.'),s&&s.length!==m*a&&b.error('The "as" parameter has too few output field names.'),s=s||l.map(b.accessorName),i=function(t){for(var e,i,n=0,r=0;n<m;++n)if(null==(i=o.get(u[n](t))))for(e=0;e<a;++e,++r)t[s[r]]=f;else for(e=0;e<a;++e,++r)t[s[r]]=l[e](i)}):(s||b.error("Missing output field names."),i=function(t){for(var e,i=0;i<m;++i)e=o.get(u[i](t)),t[s[i]]=null==e?f:e}),r?n=e.reflow(!0):d|=u.some(function(t){return e.modified(t.fields)})?e.MOD:0,e.visit(d,i),n.modifies(s)},b.inherits(nt,E.Operator),b.inherits(at,E.Operator),b.inherits(ut,E.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=b.inherits(ot,r);function ft(t){L.call(this,t)}function dt(t){E.Transform.call(this,null,t)}function mt(t){E.Transform.call(this,null,t)}function ct(t){E.Transform.call(this,null,t)}function ht(t){E.Transform.call(this,[],t),this.count=0}function pt(t){E.Transform.call(this,null,t)}function vt(t){E.Transform.call(this,null,t),this.modified(!0)}function gt(t){E.Transform.call(this,b.fastmap(),t)}function yt(t){E.Transform.call(this,null,t)}lt._transform=lt.transform,lt.transform=function(t,e){return this._transform((n=e,a=(i=t).field,s=i.value,r=("count"===i.op?"__count__":i.op)||"sum",u=b.accessorFields(a).concat(b.accessorFields(s)),l=a,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 r}),fields:o.map(function(t){return e=t,i=a,n=s,r=u,b.accessor(function(t){return i(t)===e?n(t):NaN},r,e+"");var e,i,n,r}),as:o.map(function(t){return t+""}),modified:i.modified.bind(i)}),e);var i,n,a,s,r,u,o,l,f,d,m,c},b.inherits(ft,L).transform=function(t,i){var n=this,r=t.subflow,a=t.field;return(t.modified("field")||a&&i.modified(b.accessorFields(a)))&&b.error("PreFacet does not support field modification."),this._targets.active=0,i.visit(i.MOD,function(t){var e=n.subflow(E.tupleid(t),r,i,t);a?a(t).forEach(function(t){e.mod(t)}):e.mod(t)}),i.visit(i.ADD,function(t){var e=n.subflow(E.tupleid(t),r,i,t);a?a(t).forEach(function(t){e.add(E.ingest(t))}):e.add(t)}),i.visit(i.REM,function(t){var e=n.subflow(E.tupleid(t),r,i,t);a?a(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}]},b.inherits(dt,E.Transform).transform=function(t,e){var i,n,r=t.fields,a=B(t.fields,t.as||[]),s=r?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,r,a)}:E.rederive;return this.value?n=this.value:(e=e.addAll(),n=this.value={}),i=e.fork(e.NO_SOURCE),e.visit(e.REM,function(t){var e=E.tupleid(t);i.rem.push(n[e]),n[e]=null}),e.visit(e.ADD,function(t){var e=s(t,E.ingest({}));n[E.tupleid(t)]=e,i.add.push(e)}),e.visit(e.MOD,function(t){i.mod.push(s(t,n[E.tupleid(t)]))}),i},b.inherits(mt,E.Transform).transform=function(t,e){return this.value=t.value,t.modified("value")?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation},b.inherits(ct,E.Transform).transform=function(t,e){var i,n;return this.value?n=this.value:(i=e=e.addAll(),n=this.value={}),t.derive&&(i=e.fork(e.NO_SOURCE),e.visit(e.REM,function(t){var e=E.tupleid(t);i.rem.push(n[e]),n[e]=null}),e.visit(e.ADD,function(t){var e=E.derive(t);n[E.tupleid(t)]=e,i.add.push(e)}),e.visit(e.MOD,function(t){i.mod.push(E.rederive(t,n[E.tupleid(t)]))})),i},ht.Definition={type:"Sample",metadata:{},params:[{name:"size",type:"number",default:1e3}]},b.inherits(ht,E.Transform).transform=function(t,e){var n=e.fork(e.NO_SOURCE),i=t.modified("size"),r=t.size,a=this.value,s=this.count,u=0,o=a.reduce(function(t,e){return t[E.tupleid(e)]=1,t},{});function l(t){var e,i;a.length<r?a.push(t):(i=~~((s+1)*m.random()))<a.length&&u<=i&&(e=a[i],o[E.tupleid(e)]&&n.rem.push(e),a[i]=t),++s}if(e.rem.length&&(e.visit(e.REM,function(t){var e=E.tupleid(t);o[e]&&(o[e]=-1,n.rem.push(t)),--s}),a=a.filter(function(t){return-1!==o[E.tupleid(t)]})),(e.rem.length||i)&&a.length<r&&e.source&&(u=s=a.length,e.visit(e.SOURCE,function(t){o[E.tupleid(t)]||l(t)}),u=-1),i&&a.length>r){for(var f=0,d=a.length-r;f<d;++f)o[E.tupleid(a[f])]=-1,n.rem.push(a[f]);a=a.slice(d)}return e.mod.length&&e.visit(e.MOD,function(t){o[E.tupleid(t)]&&n.mod.push(t)}),e.add.length&&e.visit(e.ADD,l),(e.add.length||u<0)&&(n.add=a.filter(function(t){return!o[E.tupleid(t)]})),this.count=s,this.value=n.source=a,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"}]},b.inherits(pt,E.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,E.ingest(e)}),i.add=e.add.concat(this.value),i}},b.inherits(vt,E.Transform).transform=function(t,e){return this.value=e.source,e.changed()?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation},b.inherits(gt,E.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()},b.inherits(yt,E.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 r;return{init:function(){r=0},next:function(t){var e=t.index,i=t.data,n=t.compare;if(r<e){for(;e+1<i.length&&!n(i[e],i[e+1]);)++e;r=e}return(1+r)/i.length}}},ntile:function(t,e){0<(e=+e)||b.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,r){return r=+r||1,{next:function(t){var e=t.index+r,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)||b.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=b.array(t.ops),d=b.array(t.fields),m=b.array(t.params),c=b.array(t.as),h=this.outputs=[],p=this.windows=[],i={},v={},g=!0,y=[],_=[];function x(t){b.array(b.accessorFields(t)).forEach(function(t){i[t]=1})}x(t.sort),e.forEach(function(t,e){var i,n,r,a,s,u=d[e],o=b.accessorName(u),l=O(t,o,c[e]);if(x(u),h.push(l),_t.hasOwnProperty(t))p.push((i=t,n=d[e],r=m[e],a=l,{init:(s=_t[i](n,r)).init||b.zero,update:function(t,e){e[a]=s.next(t)}}));else{if(null==u&&"count"!==t&&b.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,r){t=t.map(function(t){return k(t,t.field)});var a={num:0,agg:null,store:!1,count:n};if(!r)for(var i=t.length,s=a.agg=Array(i),e=0;e<i;++e)s[e]=new t[e](a);if(a.store)var u=a.data=new o;return a.add=function(t){if(a.num+=1,!r){u&&u.add(t);for(var e=0;e<i;++e)s[e].add(s[e].get(t),t)}},a.rem=function(t){if(a.num-=1,!r){u&&u.rem(t);for(var e=0;e<i;++e)s[e].rem(s[e].get(t),t)}},a.set=function(t){var e,i;for(u&&u.values(),e=0,i=n.length;e<i;++e)t[n[e]]=a.num;if(!r)for(e=0,i=s.length;e<i;++e)s[e].set(t)},a.init=function(){a.num=0,u&&u.reset();for(var t=0;t<i;++t)s[t].init()},a}(_,y,g)),this.inputs=Object.keys(i)}var Dt=Ot.prototype;function bt(t){E.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,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)},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=b.inherits(bt,E.Transform);function kt(t,e,i){var n=i.sort,r=n&&!i.ignorePeers,a=i.frame||[null,0],s=t.data(n),u=s.length,o=0,l=r?d.bisector(n):null,f={i0:0,i1:0,p0:0,p1:0,index:0,data:s,compare:n||b.constant(-1)};for(e.init();o<u;++o)qt(f,a,o,u),r&&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,r=t.compare,a=t.data,s=a.length-1;0<i&&!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]))}Et.transform=function(t,e){var i,n,r=this,a=r.state,s=t.modified();this.stamp=e.stamp,a&&!s||(a=r.state=new Ot(t));var u=v(t.groupby);function o(t){return r.group(u(t))}for(s||e.modified(a.inputs)?(r.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=r._mlen;i<n;++i)kt(r._mods[i],a,t);return r._mlen=0,r._mods=[],e.reflow(s).modifies(a.outputs)},Et.group=function(t){var e=this,i=e.value[t];return i||((i=e.value[t]=c(E.tupleid)).stamp=-1),i.stamp<e.stamp&&(i.stamp=e.stamp,e._mods[e._mlen++]=i),i},t.aggregate=r,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=at,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.vega=t.vega||{},t.vega.transforms={}),t.vega,t.vega,t.vega,t.d3)}(this,function(t,b,E,m,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=b.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||b.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?b.field(t):E.tupleid,this.reset()}var n=o.prototype;function a(t){E.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=b.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=b.inherits(a,E.Transform);function s(t){E.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=b.array(b.accessorFields(t)),n=0,a=i.length;n<a;++n)s[e=i[n]]||(s[e]=1,r.push(e))}this._dims=b.array(t.groupby),this._dnames=this._dims.map(function(t){var e=b.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&&b.error("Unmatched number of fields and aggregate ops."),f=0;f<h;++f)e=d[f],a=m[f],null==e&&"count"!==a&&b.error("Null aggregate field specified."),l=O(a,o=b.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?E.replace(e.tuple,s):E.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=b.inherits(s,E.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?b.merge(t,a,r.sort(t)):a.concat(r),r=[]),a}}}function h(t){E.Transform.call(this,[],t)}function p(t){E.Operator.call(this,null,g,t)}function g(t){return this.value&&!t.modified()?this.value:b.compare(t.fields,t.orders)}function y(t){E.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(b.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=b.accessor(o,b.accessorFields(n),t.name||"bin_"+b.accessorName(n))},h.Definition={type:"Collect",metadata:{source:!0},params:[{name:"sort",type:"compare"}]},b.inherits(h,E.Transform).transform=function(t,e){var i=e.fork(e.ALL),n=c(E.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},b.inherits(p,E.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 _=b.inherits(y,E.Transform);function x(t){E.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=E.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"]}]},b.inherits(x,E.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(E.ingest(u)),(u={})[e]=r);return s}(n,r,s,t.filter||b.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){E.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){E.Operator.call(this,null,A,t),this.modified(!0)}function A(e){var i=e.expr;return this.value&&!e.modified("expr")?this.value:b.accessor(function(t){return i(t,e)},b.accessorFields(i),b.accessorName(i))}function U(t){E.Transform.call(this,[void 0,void 0],t)}function F(t,e){E.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"]}]},b.inherits(R,E.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)||b.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&&b.error("Invalid density method: "+r),t.extent||a.data||b.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),E.ingest(e)});this.value&&(n.rem=this.value),this.value=n.add=n.source=l}return n},b.inherits(C,E.Operator),U.Definition={type:"Extent",metadata:{},params:[{name:"field",type:"field",required:!0}]},b.inherits(U,E.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=b.inherits(F,E.Operator);function L(t){E.Transform.call(this,{},t),this._keys=b.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=b.inherits(L,E.Transform);function I(t){E.Operator.call(this,null,j,t)}function j(t){return this.value&&!t.modified()?this.value:b.isArray(t.name)?b.array(t.name).map(function(t){return b.field(t)}):b.field(t.name,t.as)}function W(t){E.Transform.call(this,b.fastmap(),t)}function B(t,i){return t?t.map(function(t,e){return i[e]||b.accessorName(t)}):null}function J(t){E.Transform.call(this,[],t)}function K(t){E.Transform.call(this,[],t)}function $(t){E.Transform.call(this,null,t)}function G(t){E.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=E.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(E.tupleid(t),e),o(e).add(t)}),u||e.modified(a.fields)?e.visit(e.MOD,function(t){var e=E.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(E.tupleid(t))).mod(t)}),u&&e.visit(e.REFLOW,function(t){var e=E.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},b.inherits(I,E.Operator),W.Definition={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]},b.inherits(W,E.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=E.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=E.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(E.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}]},b.inherits(J,E.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=E.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"]}]},b.inherits(K,E.Transform).transform=function(t,e){var n=e.fork(e.NO_SOURCE),a=t.fields,r=a.map(b.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=E.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"}]},b.inherits($,E.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)})},b.inherits(G,E.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=E.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){E.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}]},b.inherits(V,E.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];b.error("Unrecognized imputation method: "+i)}(t),p=(m=t.field,function(t){return t?m(t):NaN}),v=b.accessorName(t.field),g=b.accessorName(t.key),y=(t.groupby||[]).map(b.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(E.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=b.inherits(X,a);function Z(t){E.Operator.call(this,null,tt,t)}function tt(t){return this.value&&!t.modified()?this.value:b.key(t.fields,t.flat)}function et(t){E.Transform.call(this,null,t)}function it(t){E.Transform.call(this,{},t)}function nt(t){E.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){E.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){E.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){b.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},b.inherits(Z,E.Operator),b.inherits(et,E.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}]},b.inherits(it,E.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&&b.error('Multi-field lookup requires explicit "as" parameter.'),s&&s.length!==m*r&&b.error('The "as" parameter has too few output field names.'),s=s||l.map(b.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||b.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)},b.inherits(nt,E.Operator),b.inherits(rt,E.Operator),b.inherits(ut,E.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=b.inherits(ot,a);function ft(t){L.call(this,t)}function dt(t){E.Transform.call(this,null,t)}function mt(t){E.Transform.call(this,null,t)}function ct(t){E.Transform.call(this,null,t)}function ht(t){E.Transform.call(this,[],t),this.count=0}function pt(t){E.Transform.call(this,null,t)}function vt(t){E.Transform.call(this,null,t),this.modified(!0)}function gt(t){E.Transform.call(this,b.fastmap(),t)}function yt(t){E.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=b.accessorFields(r).concat(b.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,b.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},b.inherits(ft,L).transform=function(t,i){var n=this,a=t.subflow,r=t.field;return(t.modified("field")||r&&i.modified(b.accessorFields(r)))&&b.error("PreFacet does not support field modification."),this._targets.active=0,i.visit(i.MOD,function(t){var e=n.subflow(E.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(E.tupleid(t),a,i,t);r?r(t).forEach(function(t){e.add(E.ingest(t))}):e.add(t)}),i.visit(i.REM,function(t){var e=n.subflow(E.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}]},b.inherits(dt,E.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)}:E.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=E.tupleid(t);i.rem.push(n[e]),n[e]=null}),e.visit(e.ADD,function(t){var e=s(t,E.ingest({}));n[E.tupleid(t)]=e,i.add.push(e)}),e.visit(e.MOD,function(t){i.mod.push(s(t,n[E.tupleid(t)]))}),i},b.inherits(mt,E.Transform).transform=function(t,e){return this.value=t.value,t.modified("value")?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation},b.inherits(ct,E.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=E.tupleid(t);i.rem.push(n[e]),n[e]=null}),e.visit(e.ADD,function(t){var e=E.derive(t);n[E.tupleid(t)]=e,i.add.push(e)}),e.visit(e.MOD,function(t){i.mod.push(E.rederive(t,n[E.tupleid(t)]))})),i},ht.Definition={type:"Sample",metadata:{},params:[{name:"size",type:"number",default:1e3}]},b.inherits(ht,E.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[E.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[E.tupleid(e)]&&n.rem.push(e),r[i]=t),++s}if(e.rem.length&&(e.visit(e.REM,function(t){var e=E.tupleid(t);o[e]&&(o[e]=-1,n.rem.push(t)),--s}),r=r.filter(function(t){return-1!==o[E.tupleid(t)]})),(e.rem.length||i)&&r.length<a&&e.source&&(u=s=r.length,e.visit(e.SOURCE,function(t){o[E.tupleid(t)]||l(t)}),u=-1),i&&r.length>a){for(var f=0,d=r.length-a;f<d;++f)o[E.tupleid(r[f])]=-1,n.rem.push(r[f]);r=r.slice(d)}return e.mod.length&&e.visit(e.MOD,function(t){o[E.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[E.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"}]},b.inherits(pt,E.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,E.ingest(e)}),i.add=e.add.concat(this.value),i}},b.inherits(vt,E.Transform).transform=function(t,e){return this.value=e.source,e.changed()?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation},b.inherits(gt,E.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()},b.inherits(yt,E.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)||b.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)||b.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=b.array(t.ops),d=b.array(t.fields),m=b.array(t.params),c=b.array(t.as),h=this.outputs=[],p=this.windows=[],i={},v={},g=!0,y=[],_=[];function x(t){b.array(b.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=b.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||b.zero,update:function(t,e){e[r]=s.next(t)}}));else{if(null==u&&"count"!==t&&b.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){E.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=b.inherits(bt,E.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||b.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(E.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})});
{
"name": "vega-transforms",
"version": "2.2.0",
"version": "2.3.0",
"description": "Data processing transforms for Vega dataflows.",

@@ -37,5 +37,5 @@ "keywords": [

"dependencies": {
"d3-array": "^1.2.1",
"d3-array": "^1.2.4",
"vega-dataflow": "^4.0.4",
"vega-statistics": "^1.2.1",
"vega-statistics": "^1.2.2",
"vega-util": "^1.7.0"

@@ -45,3 +45,3 @@ },

"eslint": "5",
"rollup": "0.62.0",
"rollup": "0.66.6",
"tape": "4",

@@ -48,0 +48,0 @@ "uglify-js": "3"

@@ -11,3 +11,3 @@ import {Transform} from 'vega-dataflow';

export default function Extent(params) {
Transform.call(this, [+Infinity, -Infinity], params);
Transform.call(this, [undefined, undefined], params);
}

@@ -30,3 +30,2 @@

max = extent[1],
flag = pulse.ADD,
mod;

@@ -38,4 +37,3 @@

if (mod) {
flag = pulse.SOURCE;
if (mod || min == null) {
min = +Infinity;

@@ -45,3 +43,3 @@ max = -Infinity;

pulse.visit(flag, function(t) {
pulse.visit(mod ? pulse.SOURCE : pulse.ADD, function(t) {
var v = field(t);

@@ -57,3 +55,6 @@ if (v != null) {

if (!isFinite(min) || !isFinite(max)) {
min = max = undefined;
}
this.value = [min, max];
};

@@ -32,3 +32,3 @@ import {extend, identity} from 'vega-util';

init: 'this.sum = 0;',
add: 'this.sum += v;',
add: 'this.sum += +v;',
rem: 'this.sum -= v;',

@@ -42,7 +42,7 @@ set: 'this.sum'

rem: 'var d = v - this.mean; this.mean -= this.valid ? d / this.valid : this.mean;',
set: 'this.mean'
set: 'this.valid ? this.mean : undefined'
}),
'average': measure({
name: 'average',
set: 'this.mean',
set: 'this.valid ? this.mean : undefined',
req: ['mean'], idx: 1

@@ -55,3 +55,3 @@ }),

rem: 'this.dev -= d * (v - this.mean);',
set: 'this.valid > 1 ? this.dev / (this.valid-1) : 0',
set: 'this.valid > 1 ? this.dev / (this.valid-1) : undefined',
req: ['mean'], idx: 1

@@ -61,3 +61,3 @@ }),

name: 'variancep',
set: 'this.valid > 1 ? this.dev / this.valid : 0',
set: 'this.valid > 1 ? this.dev / this.valid : undefined',
req: ['variance'], idx: 2

@@ -67,3 +67,3 @@ }),

name: 'stdev',
set: 'this.valid > 1 ? Math.sqrt(this.dev / (this.valid-1)) : 0',
set: 'this.valid > 1 ? Math.sqrt(this.dev / (this.valid-1)) : undefined',
req: ['variance'], idx: 2

@@ -73,3 +73,3 @@ }),

name: 'stdevp',
set: 'this.valid > 1 ? Math.sqrt(this.dev / this.valid) : 0',
set: 'this.valid > 1 ? Math.sqrt(this.dev / this.valid) : undefined',
req: ['variance'], idx: 2

@@ -79,3 +79,3 @@ }),

name: 'stderr',
set: 'this.valid > 1 ? Math.sqrt(this.dev / (this.valid * (this.valid-1))) : 0',
set: 'this.valid > 1 ? Math.sqrt(this.dev / (this.valid * (this.valid-1))) : undefined',
req: ['variance'], idx: 2

@@ -115,5 +115,5 @@ }),

name: 'argmin',
init: 'this.argmin = null;',
init: 'this.argmin = undefined;',
add: 'if (v < this.min) this.argmin = t;',
rem: 'if (v <= this.min) this.argmin = null;',
rem: 'if (v <= this.min) this.argmin = undefined;',
set: 'this.argmin || cell.data.argmin(this.get)',

@@ -124,5 +124,5 @@ req: ['min'], str: ['values'], idx: 3

name: 'argmax',
init: 'this.argmax = null;',
init: 'this.argmax = undefined;',
add: 'if (v > this.max) this.argmax = t;',
rem: 'if (v >= this.max) this.argmax = null;',
rem: 'if (v >= this.max) this.argmax = undefined;',
set: 'this.argmax || cell.data.argmax(this.get)',

@@ -133,4 +133,4 @@ req: ['max'], str: ['values'], idx: 3

name: 'min',
init: 'this.min = null;',
add: 'if (v < this.min || this.min === null) this.min = v;',
init: 'this.min = undefined;',
add: 'if (v < this.min || this.min === undefined) this.min = v;',
rem: 'if (v <= this.min) this.min = NaN;',

@@ -142,4 +142,4 @@ set: 'this.min = (isNaN(this.min) ? cell.data.min(this.get) : this.min)',

name: 'max',
init: 'this.max = null;',
add: 'if (v > this.max || this.max === null) this.max = v;',
init: 'this.max = undefined;',
add: 'if (v > this.max || this.max === undefined) this.max = v;',
rem: 'if (v >= this.max) this.max = NaN;',

@@ -146,0 +146,0 @@ set: 'this.max = (isNaN(this.max) ? cell.data.max(this.get) : this.max)',

@@ -95,3 +95,3 @@ import {tupleid} from 'vega-dataflow';

var m = this.extent(get)[0];
return m != null ? get(m) : +Infinity;
return m != null ? get(m) : undefined;
};

@@ -101,3 +101,3 @@

var m = this.extent(get)[1];
return m != null ? get(m) : -Infinity;
return m != null ? get(m) : undefined;
};

@@ -104,0 +104,0 @@

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

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