Socket
Socket
Sign inDemoInstall

vega-dataflow

Package Overview
Dependencies
Maintainers
2
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-dataflow - npm Package Compare versions

Comparing version 4.1.0 to 5.0.0

2

build/vega-dataflow.min.js

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

!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-loader"),require("vega-util")):"function"==typeof define&&define.amd?define(["exports","vega-loader","vega-util"],n):n(t.vega={},t.vega,t.vega)}(this,function(t,h,m){"use strict";function l(t){var r=t||m.identity,i=[],s={};return i.add=function(t){var n=r(t);return s[n]||(s[n]=1,i.push(t)),i},i.remove=function(t){var n,e=r(t);return s[e]&&(s[e]=0)<=(n=i.indexOf(t))&&i.splice(n,1),i},i}var e=Symbol("vega_id"),r=1;function _(t){return t[e]}function i(t,n){return t[e]=n,t}function y(t){var n=t===Object(t)?t:{data:t};return _(n)?n:i(n,r++)}function n(t,n){for(var e in t)n[e]=t[e];return n}function c(t){return t&&t.constructor===s}function s(){var c=[],f=[],d=[],p=[],v=[],g=!1;return{constructor:s,insert:function(t){for(var n=m.array(t),e=0,r=n.length;e<r;++e)c.push(n[e]);return this},remove:function(t){for(var n=m.isFunction(t)?p:f,e=m.array(t),r=0,i=e.length;r<i;++r)n.push(e[r]);return this},modify:function(t,n,e){var r={field:n,value:m.constant(e)};return m.isFunction(t)?(r.filter=t,v.push(r)):(r.tuple=t,d.push(r)),this},encode:function(t,n){return m.isFunction(t)?v.push({filter:t,field:n}):d.push({tuple:t,field:n}),this},reflow:function(){return g=!0,this},pulse:function(r,t){var n,e,i,s,u,o,a={},l={};for(n=0,e=t.length;n<e;++n)a[_(t[n])]=1;for(n=0,e=f.length;n<e;++n)a[_(u=f[n])]=-1;for(n=0,e=p.length;n<e;++n)s=p[n],t.forEach(function(t){s(t)&&(a[_(t)]=-1)});for(n=0,e=c.length;n<e;++n)o=_(u=c[n]),a[o]?a[o]=1:r.add.push(y(c[n]));for(n=0,e=t.length;n<e;++n)u=t[n],a[_(u)]<0&&r.rem.push(u);function h(t,n,e){e?t[n]=e(t):r.encode=n,g||(l[_(t)]=t)}for(n=0,e=d.length;n<e;++n)u=(i=d[n]).tuple,s=i.field,0<(o=a[_(u)])&&(h(u,s,i.value),r.modifies(s));for(n=0,e=v.length;n<e;++n)i=v[n],s=i.filter,t.forEach(function(t){s(t)&&0<a[_(t)]&&h(t,i.field,i.value)}),r.modifies(i.field);if(g)r.mod=f.length||p.length?t.filter(function(t){return 0<a[_(t)]}):t.slice();else for(o in l)r.mod.push(l[o]);return r}}}var u="_:mod:_";function f(){Object.defineProperty(this,u,{writable:!0,value:{}})}var o=f.prototype;o.set=function(t,n,e,r){var i=this[t],s=this[u];return null!=n&&0<=n?(i[n]!==e||r)&&(i[n]=e,s[n+":"+t]=-1,s[t]=-1):(i!==e||r)&&(this[t]=e,s[t]=m.isArray(e)?1+e.length:-1),this},o.modified=function(t,n){var e,r=this[u];if(!arguments.length){for(e in r)if(r[e])return!0;return!1}if(m.isArray(t)){for(e=0;e<t.length;++e)if(r[t[e]])return!0;return!1}return null!=n&&0<=n?n+1<r[t]||!!r[n+":"+t]:!!r[t]},o.clear=function(){return this[u]={},this};var a=0,d=new f;function p(t,n,e,r){this.id=++a,this.value=t,this.stamp=-1,this.rank=-1,this.qrank=-1,this.flags=0,n&&(this._update=n),e&&this.parameters(e,r)}var v=p.prototype;function g(e){return function(t){var n=this.flags;return 0===arguments.length?!!(n&e):(this.flags=t?n|e:n&~e,this)}}v.targets=function(){return this._targets||(this._targets=l(m.id))},v.set=function(t){return this.value!==t?(this.value=t,1):0},v.skip=g(1),v.modified=g(2),v.parameters=function(t,r,n){r=!1!==r;var e,i,s,u,o=this,a=o._argval=o._argval||new f,l=o._argops=o._argops||[],h=[];function c(t,n,e){e instanceof p?(e!==o&&(r&&e.targets().add(o),h.push(e)),l.push({op:e,name:t,index:n})):a.set(t,n,e)}for(e in t)if(i=t[e],"pulse"===e)m.array(i).forEach(function(t){t instanceof p?t!==o&&(t.targets().add(o),h.push(t)):m.error("Pulse parameters must be operator instances.")}),o.source=i;else if(m.isArray(i))for(a.set(e,-1,Array(s=i.length)),u=0;u<s;++u)c(e,u,i[u]);else c(e,-1,i);return this.marshall().clear(),n&&(l.initonly=!0),h},v.marshall=function(t){var n,e,r,i,s,u=this._argval||d,o=this._argops;if(o){for(e=0,r=o.length;e<r;++e)s=(i=(n=o[e]).op).modified()&&i.stamp===t,u.set(n.name,n.index,i.value,s);if(o.initonly){for(e=0;e<r;++e)(n=o[e]).op.targets().remove(this);this._argops=null,this._update=null}}return u},v.evaluate=function(t){var n=this._update;if(n){var e=this.marshall(t.stamp),r=n.call(this,e,t);if(e.clear(),r!==this.value)this.value=r;else if(!this.modified())return t.StopPropagation}},v.run=function(t){return t.stamp<=this.stamp?t.StopPropagation:(this.skip()?(this.skip(!1),n=0):n=this.evaluate(t),this.stamp=t.stamp,this.pulse=n||t);var n};var k=0;function F(t,n,e){this.id=++k,this.value=null,e&&(this.receive=e),t&&(this._filter=t),n&&(this._apply=n)}function w(t,n,e){return new F(t,n,e)}var A=F.prototype;A._filter=m.truthy,A._apply=m.identity,A.targets=function(){return this._targets||(this._targets=l(m.id))},A.consume=function(t){return arguments.length?(this._consume=!!t,this):!!this._consume},A.receive=function(t){if(this._filter(t)){for(var n=this.value=this._apply(t),e=this._targets,r=e?e.length:0,i=0;i<r;++i)e[i].receive(n);this._consume&&(t.preventDefault(),t.stopPropagation())}},A.filter=function(t){var n=w(t);return this.targets().add(n),n},A.apply=function(t){var n=w(null,t);return this.targets().add(n),n},A.merge=function(){var t=w();this.targets().add(t);for(var n=0,e=arguments.length;n<e;++n)arguments[n].targets().add(t);return t},A.throttle=function(n){var e=-1;return this.filter(function(){var t=Date.now();return n<t-e?(e=t,1):0})},A.debounce=function(t){var e=w();return this.targets().add(w(null,null,m.debounce(t,function(t){var n=t.dataflow;e.receive(t),n&&n.run&&n.run()}))),e},A.between=function(t,n){var e=!1;return t.targets().add(w(null,null,function(){e=!0})),n.targets().add(w(null,null,function(){e=!1})),this.filter(function(){return e})};var D={skip:!0};function O(r,t,i,n,e,s){var u,o,a=m.extend({},s,D);m.isFunction(i)||(i=m.constant(i)),void 0===n?u=function(t){r.touch(i(t))}:m.isFunction(n)?(o=new p(null,n,e,!1),u=function(t){var n,e=i(t);o.evaluate(t),c(n=o.value)?r.pulse(e,n,s):r.update(e,n,a)}):u=function(t){r.update(i(t),n,a)},t.apply(u)}function P(t,n,r,e,i,s){var u,o;void 0===e?o=r:(u=m.isFunction(e)?e:m.constant(e),(o=new p(null,e=r?function(t,n){var e=u(t,n);return r.skip()||(r.skip(e!==this.value).value=e),e}:u,i,!1)).modified(s&&s.force),o.rank=0,r&&(o.skip(!0),o.value=r.value,o.targets().add(r))),n.targets().add(o)}var E={};function q(t,n,e){this.dataflow=t,this.stamp=null==n?-1:n,this.add=[],this.rem=[],this.mod=[],this.fields=null,this.encode=e||null}var b=q.prototype;function M(e,r){return e?function(t,n){return e(t,n)&&r(t,n)}:r}function S(t,n){var e=[];return m.visitArray(t,n,function(t){e.push(t)}),e}function L(t,n){var e={};return t.visit(n,function(t){e[_(t)]=1}),function(t){return e[_(t)]?null:t}}function R(t,n,e,r){var i,s,u,o,a,l=this,h=0;for(this.dataflow=t,this.stamp=n,this.fields=null,this.encode=r||null,u=0,o=(this.pulses=e).length;u<o;++u)if((i=e[u]).stamp===n){if(i.fields)for(a in s=l.fields||(l.fields={}),i.fields)s[a]=1;i.changed(l.ADD)&&(h|=l.ADD),i.changed(l.REM)&&(h|=l.REM),i.changed(l.MOD)&&(h|=l.MOD)}this.changes=h}b.StopPropagation=E,b.ADD=1,b.REM=2,b.MOD=4,b.ADD_REM=3,b.ADD_MOD=5,b.ALL=7,b.REFLOW=8,b.SOURCE=16,b.NO_SOURCE=32,b.NO_FIELDS=64,b.fork=function(t){return new q(this.dataflow).init(this,t)},b.clone=function(){var t=this.fork(7);return t.add=t.add.slice(),t.rem=t.rem.slice(),t.mod=t.mod.slice(),t.source&&(t.source=t.source.slice()),t.materialize(23)},b.addAll=function(){var t=this;return this.source&&this.source.length!==this.add.length&&((t=new q(this.dataflow).init(this)).add=t.source),t},b.init=function(t,n){var e=this;return e.stamp=t.stamp,e.encode=t.encode,!t.fields||64&n||(e.fields=t.fields),1&n?(e.addF=t.addF,e.add=t.add):(e.addF=null,e.add=[]),2&n?(e.remF=t.remF,e.rem=t.rem):(e.remF=null,e.rem=[]),4&n?(e.modF=t.modF,e.mod=t.mod):(e.modF=null,e.mod=[]),32&n?(e.srcF=null,e.source=null):(e.srcF=t.srcF,e.source=t.source),e},b.runAfter=function(t){this.dataflow.runAfter(t)},b.changed=function(t){var n=t||7;return 1&n&&this.add.length||2&n&&this.rem.length||4&n&&this.mod.length},b.reflow=function(t){if(t)return this.fork(7).reflow();var n=this.add.length,e=this.source&&this.source.length;return e&&e!==n&&(this.mod=this.source,n&&this.filter(4,L(this,1))),this},b.modifies=function(t){var n=m.array(t),e=this.fields||(this.fields={});return n.forEach(function(t){e[t]=!0}),this},b.modified=function(t){var n=this.fields;return!(!this.mod.length||!n)&&(arguments.length?m.isArray(t)?t.some(function(t){return n[t]}):n[t]:!!n)},b.filter=function(t,n){var e=this;return 1&t&&(e.addF=M(e.addF,n)),2&t&&(e.remF=M(e.remF,n)),4&t&&(e.modF=M(e.modF,n)),16&t&&(e.srcF=M(e.srcF,n)),e},b.materialize=function(t){var n=this;return 1&(t=t||7)&&n.addF&&(n.add=S(n.add,n.addF),n.addF=null),2&t&&n.remF&&(n.rem=S(n.rem,n.remF),n.remF=null),4&t&&n.modF&&(n.mod=S(n.mod,n.modF),n.modF=null),16&t&&n.srcF&&(n.source=n.source.filter(n.srcF),n.srcF=null),n},b.visit=function(t,n){var e,r,i=this,s=n;return 16&t?m.visitArray(i.source,i.srcF,s):(1&t&&m.visitArray(i.add,i.addF,s),2&t&&m.visitArray(i.rem,i.remF,s),4&t&&m.visitArray(i.mod,i.modF,s),8&t&&(e=i.source)&&((r=i.add.length+i.mod.length)===e.length||(r?m.visitArray(e,L(i,5),s):m.visitArray(e,i.srcF,s)))),i};var x=m.inherits(R,q);function T(n,t){try{t(n)}catch(t){n.error(t)}}x.fork=function(t){var n=new q(this.dataflow).init(this,t&this.NO_FIELDS);return void 0!==t&&(t&n.ADD&&this.visit(n.ADD,function(t){return n.add.push(t)}),t&n.REM&&this.visit(n.REM,function(t){return n.rem.push(t)}),t&n.MOD&&this.visit(n.MOD,function(t){return n.mod.push(t)})),n},x.changed=function(t){return this.changes&t},x.modified=function(t){var n=this.fields;return n&&this.changes&this.MOD?m.isArray(t)?t.some(function(t){return n[t]}):n[t]:0},x.filter=function(){m.error("MultiPulse does not support filtering.")},x.materialize=function(){m.error("MultiPulse does not support materialization.")};var z={skip:!(x.visit=function(t,n){var e=this.pulses,r=e.length,i=0;if(t&this.SOURCE)for(;i<r;++i)e[i].visit(t,n);else for(;i<r;++i)e[i].stamp===this.stamp&&e[i].visit(t,n);return this}),force:!1};function C(t){this.cmp=t,this.nodes=[]}var I=C.prototype;function U(t,n,e,r){var i,s,u;for(i=t[e];n<e&&r(i,s=t[u=e-1>>1])<0;)t[e]=s,e=u;return t[e]=i}function j(t,n,e){for(var r,i=n,s=t.length,u=t[n],o=2*n+1;o<s;)(r=o+1)<s&&0<=e(t[o],t[r])&&(o=r),t[n]=t[o],o=2*(n=o)+1;return t[n]=u,U(t,i,n,e)}function N(){this._log=m.logger(),this.logLevel(m.Error),this._clock=0,this._rank=0;try{this._loader=h.loader()}catch(t){}this._touched=l(m.id),this._pulses={},this._pulse=null,this._heap=new C(function(t,n){return t.qrank-n.qrank}),this._postrun=[]}I.size=function(){return this.nodes.length},I.clear=function(){return this.nodes=[],this},I.peek=function(){return this.nodes[0]},I.push=function(t){var n=this.nodes;return n.push(t),U(n,0,n.length-1,this.cmp)},I.pop=function(){var t,n=this.nodes,e=n.pop();return n.length?(t=n[0],n[0]=e,j(n,0,this.cmp)):t=e,t},I.replace=function(t){var n=this.nodes,e=n[0];return n[0]=t,j(n,0,this.cmp),e},I.pushpop=function(t){var n=this.nodes,e=n[0];return n.length&&this.cmp(e,t)<0&&(n[0]=t,t=e,j(n,0,this.cmp)),t};var G=N.prototype;function W(t){return function(){return this._log[t].apply(this,arguments)}}function B(t,n){p.call(this,t,null,n)}G.stamp=function(){return this._clock},G.loader=function(t){return arguments.length?(this._loader=t,this):this._loader},G.cleanThreshold=1e4,G.add=function(t,n,e,r){var i,s=1;return t instanceof p?i=t:t&&t.prototype instanceof p?i=new t:m.isFunction(t)?i=new p(null,t):(s=0,i=new p(t,n)),this.rank(i),s&&(r=e,e=n),e&&this.connect(i,i.parameters(e,r)),this.touch(i),i},G.connect=function(t,n){var e,r,i=t.rank;for(e=0,r=n.length;e<r;++e)if(i<n[e].rank)return void this.rerank(t)},G.rank=function(t){t.rank=++this._rank},G.rerank=function(t){for(var n,e,r,i=[t];i.length;)if(this.rank(n=i.pop()),e=n._targets)for(r=e.length;0<=--r;)i.push(n=e[r]),n===t&&m.error("Cycle detected in dataflow graph.")},G.pulse=function(t,n,e){this.touch(t,e||z);var r=new q(this,this._clock+(this._pulse?0:1)),i=t.pulse&&t.pulse.source||[];return r.target=t,this._pulses[t.id]=n.pulse(r,i),this},G.touch=function(t,n){var e=n||z;return this._pulse?this._enqueue(t):this._touched.add(t),e.skip&&t.skip(!0),this},G.update=function(t,n,e){var r=e||z;return(t.set(n)||r.force)&&this.touch(t,r),this},G.changeset=s,G.ingest=function(t,n,e){return this.pulse(t,this.changeset().insert(h.read(n,e)))},G.request=function(n,e,r){var i,s,u,t,o=this,a=0,l=o._pending||(i=o,(t=new Promise(function(t,n){s=function(){t(i)},u=n})).requests=0,t.done=function(){0==--t.requests&&i.runAfter(function(){i._pending=null;try{i.run(),i._pending?i._pending.then(s):s()}catch(t){u(t)}})},i._pending=t);return l.requests+=1,o.loader().load(e,{context:"dataflow"}).then(function(t){return h.read(t,r)},function(t){a=-1,o.error("Loading failed",e,t)}).catch(function(t){a=-2,o.error("Data ingestion failed",e,t)}).then(function(t){return o.pulse(n,o.changeset().remove(m.truthy).insert(t||[])),l.done(),a})},G.events=function(t,n,e,r){for(var i,s=this,u=w(e,r),o=function(t){t.dataflow=s;try{u.receive(t)}catch(t){s.error(t)}finally{s.run()}},a=0,l=(i="string"==typeof t&&"undefined"!=typeof document?document.querySelectorAll(t):m.array(t)).length;a<l;++a)i[a].addEventListener(n,o);return u},G.on=function(t,n,e,r,i){return(t instanceof p?P:O)(this,t,n,e,r,i),this},G.run=function(t){var n,e,r,i,s=this,u=0,o=s.logLevel();if(s._pending)return s.info("Awaiting requests, delaying dataflow run."),0;if(s._pulse)return s.error("Dataflow invoked recursively. Use the runAfter method to queue invocation."),0;if(!s._touched.length)return s.info("Dataflow invoked, but nothing to do."),0;s._pulse=new q(s,++s._clock,t),o>=m.Info&&(r=Date.now(),s.debug("-- START PROPAGATION ("+s._clock+") -----")),s._touched.forEach(function(t){s._enqueue(t,!0)}),s._touched=l(m.id);try{for(;0<s._heap.size();)(n=s._heap.pop()).rank===n.qrank?(e=n.run(s._getPulse(n,t)),o>=m.Debug&&s.debug(n.id,e===E?"STOP":e,n),e!==E&&(s._pulse=e,n._targets&&n._targets.forEach(function(t){s._enqueue(t)})),++u):s._enqueue(n,!0)}catch(t){i=t}if(s._pulses={},s._pulse=null,o>=m.Info&&(r=Date.now()-r,s.info("> Pulse "+s._clock+": "+u+" operators; "+r+"ms")),i&&(s._postrun=[],s.error(i)),s._onrun)try{s._onrun(s,u,i)}catch(t){s.error(t)}if(s._postrun.length){var a=s._postrun;s._postrun=[],a.sort(function(t,n){return n.priority-t.priority}).forEach(function(t){T(s,t.callback)})}return this},G.runAsync=function(){return this._pending||this.run()&&this._pending||Promise.resolve(this)},G.runAfter=function(t,n,e){this._pulse||n?this._postrun.push({priority:e||0,callback:t}):T(this,t)},G._enqueue=function(t,n){var e=!this._pulses[t.id];e&&(this._pulses[t.id]=this._pulse),(e||n)&&(t.qrank=t.rank,this._heap.push(t))},G._getPulse=function(t,n){var e,r=t.source,i=this._clock;return r&&m.isArray(r)?new R(this,i,e=r.map(function(t){return t.pulse}),n):(e=this._pulses[t.id],r&&((r=r.pulse)&&r!==E?r.stamp===i&&e.target!==t?e=r:e.source=r.source:e.source=[]),e)},G.error=W("error"),G.warn=W("warn"),G.info=W("info"),G.debug=W("debug"),G.logLevel=W("level");var H=m.inherits(B,p);H.run=function(t){return t.stamp<=this.stamp?t.StopPropagation:(this.skip()?this.skip(!1):n=this.evaluate(t),(n=n||t)!==t.StopPropagation&&(this.pulse=n),this.stamp=t.stamp,n);var n},H.evaluate=function(t){var n=this.marshall(t.stamp),e=this.transform(n,t);return n.clear(),e},H.transform=function(){};var J={};function K(t){return t=t&&t.toLowerCase(),J.hasOwnProperty(t)?J[t]:null}t.UniqueList=l,t.changeset=s,t.isChangeSet=c,t.Dataflow=N,t.EventStream=F,t.Parameters=f,t.Pulse=q,t.MultiPulse=R,t.Operator=p,t.Transform=B,t.derive=function(t){return n(t,y({}))},t.rederive=n,t.ingest=y,t.isTuple=function(t){return!(!t||!_(t))},t.replace=function(t,n){return i(n,_(t))},t.tupleid=_,t.definition=function(t){var n=K(t);return n&&n.Definition||null},t.transform=K,t.transforms=J,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-util"),require("vega-loader")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-loader"],n):n((t=t||self).vega={},t.vega,t.vega)}(this,function(t,n,e){"use strict";function r(t){var e=t||n.identity,r=[],i={};return r.add=function(t){var n=e(t);return i[n]||(i[n]=1,r.push(t)),r},r.remove=function(t){var n,s=e(t);return i[s]&&(i[s]=0,(n=r.indexOf(t))>=0&&r.splice(n,1)),r},r}var i=Symbol("vega_id"),s=1;function u(t){return t[i]}function o(t,n){return t[i]=n,t}function a(t){var n=t===Object(t)?t:{data:t};return u(n)?n:o(n,s++)}function l(t,n){for(var e in t)n[e]=t[e];return n}function h(t){return t&&t.constructor===c}function c(){var t=[],e=[],r=[],i=[],s=[],o=!1;return{constructor:c,insert:function(e){for(var r=n.array(e),i=0,s=r.length;i<s;++i)t.push(r[i]);return this},remove:function(t){for(var r=n.isFunction(t)?i:e,s=n.array(t),u=0,o=s.length;u<o;++u)r.push(s[u]);return this},modify:function(t,e,i){var u={field:e,value:n.constant(i)};return n.isFunction(t)?(u.filter=t,s.push(u)):(u.tuple=t,r.push(u)),this},encode:function(t,e){return n.isFunction(t)?s.push({filter:t,field:e}):r.push({tuple:t,field:e}),this},reflow:function(){return o=!0,this},pulse:function(n,l){var h,c,f,d,p,v,g={},m={};for(h=0,c=l.length;h<c;++h)g[u(l[h])]=1;for(h=0,c=e.length;h<c;++h)g[u(p=e[h])]=-1;for(h=0,c=i.length;h<c;++h)d=i[h],l.forEach(function(t){d(t)&&(g[u(t)]=-1)});for(h=0,c=t.length;h<c;++h)v=u(p=t[h]),g[v]?g[v]=1:n.add.push(a(t[h]));for(h=0,c=l.length;h<c;++h)p=l[h],g[u(p)]<0&&n.rem.push(p);function _(t,e,r){r?t[e]=r(t):n.encode=e,o||(m[u(t)]=t)}for(h=0,c=r.length;h<c;++h)p=(f=r[h]).tuple,d=f.field,(v=g[u(p)])>0&&(_(p,d,f.value),n.modifies(d));for(h=0,c=s.length;h<c;++h)f=s[h],d=f.filter,l.forEach(function(t){d(t)&&g[u(t)]>0&&_(t,f.field,f.value)}),n.modifies(f.field);if(o)n.mod=e.length||i.length?l.filter(function(t){return g[u(t)]>0}):l.slice();else for(v in m)n.mod.push(m[v]);return n}}}var f="_:mod:_";function d(){Object.defineProperty(this,f,{writable:!0,value:{}})}var p=d.prototype;p.set=function(t,e,r,i){var s=this,u=s[t],o=s[f];return null!=e&&e>=0?(u[e]!==r||i)&&(u[e]=r,o[e+":"+t]=-1,o[t]=-1):(u!==r||i)&&(s[t]=r,o[t]=n.isArray(r)?1+r.length:-1),s},p.modified=function(t,e){var r,i=this[f];if(!arguments.length){for(r in i)if(i[r])return!0;return!1}if(n.isArray(t)){for(r=0;r<t.length;++r)if(i[t[r]])return!0;return!1}return null!=e&&e>=0?e+1<i[t]||!!i[e+":"+t]:!!i[t]},p.clear=function(){return this[f]={},this};var v=0,g=new d;function m(t,n,e,r){this.id=++v,this.value=t,this.stamp=-1,this.rank=-1,this.qrank=-1,this.flags=0,n&&(this._update=n),e&&this.parameters(e,r)}var _=m.prototype;function y(t){return function(n){var e=this.flags;return 0===arguments.length?!!(e&t):(this.flags=n?e|t:e&~t,this)}}_.targets=function(){return this._targets||(this._targets=r(n.id))},_.set=function(t){return this.value!==t?(this.value=t,1):0},_.skip=y(1),_.modified=y(2),_.parameters=function(t,e,r){e=!1!==e;var i,s,u,o,a=this,l=a._argval=a._argval||new d,h=a._argops=a._argops||[],c=[];function f(t,n,r){r instanceof m?(r!==a&&(e&&r.targets().add(a),c.push(r)),h.push({op:r,name:t,index:n})):l.set(t,n,r)}for(i in t)if(s=t[i],"pulse"===i)n.array(s).forEach(function(t){t instanceof m?t!==a&&(t.targets().add(a),c.push(t)):n.error("Pulse parameters must be operator instances.")}),a.source=s;else if(n.isArray(s))for(l.set(i,-1,Array(u=s.length)),o=0;o<u;++o)f(i,o,s[o]);else f(i,-1,s);return this.marshall().clear(),r&&(h.initonly=!0),c},_.marshall=function(t){var n,e,r,i,s,u=this._argval||g,o=this._argops;if(o){for(e=0,r=o.length;e<r;++e)s=(i=(n=o[e]).op).modified()&&i.stamp===t,u.set(n.name,n.index,i.value,s);if(o.initonly){for(e=0;e<r;++e)(n=o[e]).op.targets().remove(this);this._argops=null,this._update=null}}return u},_.evaluate=function(t){var n=this._update;if(n){var e=this.marshall(t.stamp),r=n.call(this,e,t);if(e.clear(),r!==this.value)this.value=r;else if(!this.modified())return t.StopPropagation}},_.run=function(t){return t.stamp<=this.stamp?t.StopPropagation:(this.skip()?(this.skip(!1),n=0):n=this.evaluate(t),this.stamp=t.stamp,this.pulse=n||t);var n};var w=0;function F(t,n,e){this.id=++w,this.value=null,e&&(this.receive=e),t&&(this._filter=t),n&&(this._apply=n)}function k(t,n,e){return new F(t,n,e)}var A=F.prototype;A._filter=n.truthy,A._apply=n.identity,A.targets=function(){return this._targets||(this._targets=r(n.id))},A.consume=function(t){return arguments.length?(this._consume=!!t,this):!!this._consume},A.receive=function(t){if(this._filter(t)){for(var n=this.value=this._apply(t),e=this._targets,r=e?e.length:0,i=0;i<r;++i)e[i].receive(n);this._consume&&(t.preventDefault(),t.stopPropagation())}},A.filter=function(t){var n=k(t);return this.targets().add(n),n},A.apply=function(t){var n=k(null,t);return this.targets().add(n),n},A.merge=function(){var t=k();this.targets().add(t);for(var n=0,e=arguments.length;n<e;++n)arguments[n].targets().add(t);return t},A.throttle=function(t){var n=-1;return this.filter(function(){var e=Date.now();return e-n>t?(n=e,1):0})},A.debounce=function(t){var e=k();return this.targets().add(k(null,null,n.debounce(t,function(t){var n=t.dataflow;e.receive(t),n&&n.run&&n.run()}))),e},A.between=function(t,n){var e=!1;return t.targets().add(k(null,null,function(){e=!0})),n.targets().add(k(null,null,function(){e=!1})),this.filter(function(){return e})};const D=e.read;var O={skip:!0};function E(t,e,r,i,s,u){var o,a,l=n.extend({},u,O);n.isFunction(r)||(r=n.constant(r)),void 0===i?o=function(n){t.touch(r(n))}:n.isFunction(i)?(a=new m(null,i,s,!1),o=function(n){var e,i=r(n);a.evaluate(n),h(e=a.value)?t.pulse(i,e,u):t.update(i,e,l)}):o=function(n){t.update(r(n),i,l)},e.apply(o)}function P(t,e,r,i,s,u){var o,a;void 0===i?a=r:(o=n.isFunction(i)?i:n.constant(i),(a=new m(null,i=r?function(t,n){var e=o(t,n);return r.skip()||(r.skip(e!==this.value).value=e),e}:o,s,!1)).modified(u&&u.force),a.rank=0,r&&(a.skip(!0),a.value=r.value,a.targets().add(r))),e.targets().add(a)}var q={};function b(t,n,e){this.dataflow=t,this.stamp=null==n?-1:n,this.add=[],this.rem=[],this.mod=[],this.fields=null,this.encode=e||null}var M=b.prototype;function S(t,n){return t?function(e,r){return t(e,r)&&n(e,r)}:n}function L(t,e){var r=[];return n.visitArray(t,e,function(t){r.push(t)}),r}function R(t,n){var e={};return t.visit(n,function(t){e[u(t)]=1}),function(t){return e[u(t)]?null:t}}function x(t,n,e,r){var i,s,u,o,a,l=this,h=0;for(this.dataflow=t,this.stamp=n,this.fields=null,this.encode=r||null,this.pulses=e,u=0,o=e.length;u<o;++u)if((i=e[u]).stamp===n){if(i.fields)for(a in s=l.fields||(l.fields={}),i.fields)s[a]=1;i.changed(l.ADD)&&(h|=l.ADD),i.changed(l.REM)&&(h|=l.REM),i.changed(l.MOD)&&(h|=l.MOD)}this.changes=h}M.StopPropagation=q,M.ADD=1,M.REM=2,M.MOD=4,M.ADD_REM=3,M.ADD_MOD=5,M.ALL=7,M.REFLOW=8,M.SOURCE=16,M.NO_SOURCE=32,M.NO_FIELDS=64,M.fork=function(t){return new b(this.dataflow).init(this,t)},M.clone=function(){var t=this.fork(7);return t.add=t.add.slice(),t.rem=t.rem.slice(),t.mod=t.mod.slice(),t.source&&(t.source=t.source.slice()),t.materialize(23)},M.addAll=function(){var t=this;return this.source&&this.source.length!==this.add.length?((t=new b(this.dataflow).init(this)).add=t.source,t):t},M.init=function(t,n){var e=this;return e.stamp=t.stamp,e.encode=t.encode,!t.fields||64&n||(e.fields=t.fields),1&n?(e.addF=t.addF,e.add=t.add):(e.addF=null,e.add=[]),2&n?(e.remF=t.remF,e.rem=t.rem):(e.remF=null,e.rem=[]),4&n?(e.modF=t.modF,e.mod=t.mod):(e.modF=null,e.mod=[]),32&n?(e.srcF=null,e.source=null):(e.srcF=t.srcF,e.source=t.source),e},M.runAfter=function(t){this.dataflow.runAfter(t)},M.changed=function(t){var n=t||7;return 1&n&&this.add.length||2&n&&this.rem.length||4&n&&this.mod.length},M.reflow=function(t){if(t)return this.fork(7).reflow();var n=this.add.length,e=this.source&&this.source.length;return e&&e!==n&&(this.mod=this.source,n&&this.filter(4,R(this,1))),this},M.modifies=function(t){var e=n.array(t),r=this.fields||(this.fields={});return e.forEach(function(t){r[t]=!0}),this},M.modified=function(t){var e=this.fields;return!(!this.mod.length||!e)&&(arguments.length?n.isArray(t)?t.some(function(t){return e[t]}):e[t]:!!e)},M.filter=function(t,n){var e=this;return 1&t&&(e.addF=S(e.addF,n)),2&t&&(e.remF=S(e.remF,n)),4&t&&(e.modF=S(e.modF,n)),16&t&&(e.srcF=S(e.srcF,n)),e},M.materialize=function(t){var n=this;return 1&(t=t||7)&&n.addF&&(n.add=L(n.add,n.addF),n.addF=null),2&t&&n.remF&&(n.rem=L(n.rem,n.remF),n.remF=null),4&t&&n.modF&&(n.mod=L(n.mod,n.modF),n.modF=null),16&t&&n.srcF&&(n.source=n.source.filter(n.srcF),n.srcF=null),n},M.visit=function(t,e){var r,i,s=this,u=e;return 16&t?(n.visitArray(s.source,s.srcF,u),s):(1&t&&n.visitArray(s.add,s.addF,u),2&t&&n.visitArray(s.rem,s.remF,u),4&t&&n.visitArray(s.mod,s.modF,u),8&t&&(r=s.source)&&((i=s.add.length+s.mod.length)===r.length||(i?n.visitArray(r,R(s,5),u):n.visitArray(r,s.srcF,u))),s)};var T=n.inherits(x,b);function z(t,n){try{n(t)}catch(n){t.error(n)}}T.fork=function(t){var n=new b(this.dataflow).init(this,t&this.NO_FIELDS);return void 0!==t&&(t&n.ADD&&this.visit(n.ADD,function(t){return n.add.push(t)}),t&n.REM&&this.visit(n.REM,function(t){return n.rem.push(t)}),t&n.MOD&&this.visit(n.MOD,function(t){return n.mod.push(t)})),n},T.changed=function(t){return this.changes&t},T.modified=function(t){var e=this,r=e.fields;return r&&e.changes&e.MOD?n.isArray(t)?t.some(function(t){return r[t]}):r[t]:0},T.filter=function(){n.error("MultiPulse does not support filtering.")},T.materialize=function(){n.error("MultiPulse does not support materialization.")},T.visit=function(t,n){var e=this,r=e.pulses,i=r.length,s=0;if(t&e.SOURCE)for(;s<i;++s)r[s].visit(t,n);else for(;s<i;++s)r[s].stamp===e.stamp&&r[s].visit(t,n);return e};var C={skip:!1,force:!1};function I(t){this.cmp=t,this.nodes=[]}var U=I.prototype;function j(t,n,e,r){var i,s,u;for(i=t[e];e>n&&r(i,s=t[u=e-1>>1])<0;)t[e]=s,e=u;return t[e]=i}function N(t,n,e){for(var r,i=n,s=t.length,u=t[n],o=2*n+1;o<s;)(r=o+1)<s&&e(t[o],t[r])>=0&&(o=r),t[n]=t[o],o=2*(n=o)+1;return t[n]=u,j(t,i,n,e)}function G(){this._log=n.logger(),this.logLevel(n.Error),this._clock=0,this._rank=0;try{this._loader=e.loader()}catch(t){}this._touched=r(n.id),this._pulses={},this._pulse=null,this._heap=new I(function(t,n){return t.qrank-n.qrank}),this._postrun=[]}U.size=function(){return this.nodes.length},U.clear=function(){return this.nodes=[],this},U.peek=function(){return this.nodes[0]},U.push=function(t){var n=this.nodes;return n.push(t),j(n,0,n.length-1,this.cmp)},U.pop=function(){var t,n=this.nodes,e=n.pop();return n.length?(t=n[0],n[0]=e,N(n,0,this.cmp)):t=e,t},U.replace=function(t){var n=this.nodes,e=n[0];return n[0]=t,N(n,0,this.cmp),e},U.pushpop=function(t){var n=this.nodes,e=n[0];return n.length&&this.cmp(e,t)<0&&(n[0]=t,t=e,N(n,0,this.cmp)),t};var W=G.prototype;function B(t){return function(){return this._log[t].apply(this,arguments)}}function H(t,n){m.call(this,t,null,n)}W.stamp=function(){return this._clock},W.loader=function(t){return arguments.length?(this._loader=t,this):this._loader},W.cleanThreshold=1e4,W.add=function(t,e,r,i){var s,u=1;return t instanceof m?s=t:t&&t.prototype instanceof m?s=new t:n.isFunction(t)?s=new m(null,t):(u=0,s=new m(t,e)),this.rank(s),u&&(i=r,r=e),r&&this.connect(s,s.parameters(r,i)),this.touch(s),s},W.connect=function(t,n){var e,r,i=t.rank;for(e=0,r=n.length;e<r;++e)if(i<n[e].rank)return void this.rerank(t)},W.rank=function(t){t.rank=++this._rank},W.rerank=function(t){for(var e,r,i,s=[t];s.length;)if(this.rank(e=s.pop()),r=e._targets)for(i=r.length;--i>=0;)s.push(e=r[i]),e===t&&n.error("Cycle detected in dataflow graph.")},W.pulse=function(t,n,e){this.touch(t,e||C);var r=new b(this,this._clock+(this._pulse?0:1)),i=t.pulse&&t.pulse.source||[];return r.target=t,this._pulses[t.id]=n.pulse(r,i),this},W.touch=function(t,n){var e=n||C;return this._pulse?this._enqueue(t):this._touched.add(t),e.skip&&t.skip(!0),this},W.update=function(t,n,e){var r=e||C;return(t.set(n)||r.force)&&this.touch(t,r),this},W.changeset=c,W.ingest=function(t,n,e){return this.pulse(t,this.changeset().insert(D(n,e)))},W.parse=D,W.preload=async function(t,e,r){const i=this,s=i._pending||function(t){var n,e=new Promise(function(t){n=t});return e.requests=0,e.done=function(){0==--e.requests&&(t._pending=null,n(t))},t._pending=e}(i);s.requests+=1;const u=await i.request(e,r);return i.pulse(t,i.changeset().remove(n.truthy).insert(u.data||[])),s.done(),u},W.request=async function(t,n){const r=this;let i,s=0;try{i=await r.loader().load(t,{context:"dataflow",response:e.responseType(n&&n.type)});try{i=D(i,n)}catch(n){s=-2,r.warn("Data ingestion failed",t,n)}}catch(n){s=-1,r.warn("Loading failed",t,n)}return{data:i,status:s}},W.events=function(t,e,r,i){for(var s,u=this,o=k(r,i),a=function(t){t.dataflow=u;try{o.receive(t)}catch(t){u.error(t)}finally{u.run()}},l=0,h=(s="string"==typeof t&&"undefined"!=typeof document?document.querySelectorAll(t):n.array(t)).length;l<h;++l)s[l].addEventListener(e,a);return o},W.on=function(t,n,e,r,i){return(t instanceof m?P:E)(this,t,n,e,r,i),this},W.run=function(t){return this.runAsync(t),this},W.runAsync=async function(t){var e,i,s,u,o=this,a=0,l=o.logLevel();if(o._pulse)return o.error("Dataflow already running. Use runAsync().then to chain invocations."),o;if(o._pending&&await o._pending,!o._touched.length)return o.info("Dataflow invoked, but nothing to do."),o;o._pulse=new b(o,++o._clock,t),l>=n.Info&&(s=Date.now(),o.debug("-- START PROPAGATION ("+o._clock+") -----")),o._touched.forEach(function(t){o._enqueue(t,!0)}),o._touched=r(n.id);try{for(;o._heap.size()>0;)(e=o._heap.pop()).rank===e.qrank?(i=e.run(o._getPulse(e,t)),l>=n.Debug&&o.debug(e.id,i===q?"STOP":i,e),i.then&&(i=await i),i!==q&&(o._pulse=i,e._targets&&e._targets.forEach(t=>o._enqueue(t))),++a):o._enqueue(e,!0)}catch(t){u=t}if(o._pulses={},o._pulse=null,l>=n.Info&&(s=Date.now()-s,o.info("> Pulse "+o._clock+": "+a+" operators; "+s+"ms")),u&&(o._postrun=[],o.error(u)),o._onrun)try{o._onrun(o,a,u)}catch(t){o.error(t)}if(o._postrun.length){var h=o._postrun;o._postrun=[],h.sort((t,n)=>n.priority-t.priority).forEach(t=>z(o,t.callback))}return o},W.runAfter=function(t,n,e){this._pulse||n?this._postrun.push({priority:e||0,callback:t}):z(this,t)},W._enqueue=function(t,n){var e=!this._pulses[t.id];e&&(this._pulses[t.id]=this._pulse),(e||n)&&(t.qrank=t.rank,this._heap.push(t))},W._getPulse=function(t,e){var r,i=t.source,s=this._clock;return i&&n.isArray(i)?new x(this,s,r=i.map(function(t){return t.pulse}),e):(r=this._pulses[t.id],i&&((i=i.pulse)&&i!==q?i.stamp===s&&r.target!==t?r=i:r.source=i.source:r.source=[]),r)},W.error=B("error"),W.warn=B("warn"),W.info=B("info"),W.debug=B("debug"),W.logLevel=B("level");var J=n.inherits(H,m);J.run=function(t){return t.stamp<=this.stamp?t.StopPropagation:(this.skip()?this.skip(!1):n=this.evaluate(t),n=n||t,this.stamp=t.stamp,n.then?n=n.then(t=>this.pulse=t):n!==t.StopPropagation&&(this.pulse=n),n);var n},J.evaluate=function(t){var n=this.marshall(t.stamp),e=this.transform(n,t);return n.clear(),e},J.transform=function(){};var K={};function Q(t){return t=t&&t.toLowerCase(),K.hasOwnProperty(t)?K[t]:null}t.UniqueList=r,t.changeset=c,t.isChangeSet=h,t.Dataflow=G,t.EventStream=F,t.Parameters=d,t.Pulse=b,t.MultiPulse=x,t.Operator=m,t.Transform=H,t.derive=function(t){return l(t,a({}))},t.rederive=l,t.ingest=a,t.isTuple=function(t){return!(!t||!u(t))},t.replace=function(t,n){return o(n,u(t))},t.tupleid=u,t.definition=function(t){var n=Q(t);return n&&n.Definition||null},t.transform=Q,t.transforms=K,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "vega-dataflow",
"version": "4.1.0",
"version": "5.0.0",
"description": "Reactive dataflow processing.",

@@ -13,30 +13,20 @@ "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-dataflow.js",
"module": "index",
"jsnext:main": "index",
"repository": {
"type": "git",
"url": "https://github.com/vega/vega-dataflow.git"
},
"repository": "vega/vega",
"scripts": {
"build": "npm run test && uglifyjs build/vega-dataflow.js -c -m -o build/vega-dataflow.min.js",
"pretest": "rm -rf build && mkdir build && rollup -g vega-loader:vega,vega-util:vega -f umd -n vega -o build/vega-dataflow.js -- index.js",
"rollup": "rollup -g vega-loader:vega,vega-util:vega -f umd -n vega -o build/vega-dataflow.js -- index.js",
"prebuild": "rimraf build && mkdir build",
"build": "yarn rollup",
"postbuild": "terser build/vega-dataflow.js -c -m -o build/vega-dataflow.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-dataflow.zip -- LICENSE README.md build/vega-dataflow.js build/vega-dataflow.min.js"
"prepublishOnly": "yarn test && yarn build",
"postpublish": "git push && git push --tags"
},
"dependencies": {
"vega-loader": "^3.1.0",
"vega-util": "^1.7.0"
},
"devDependencies": {
"eslint": "5",
"rollup": "0.67.4",
"tape": "4",
"uglify-js": "3"
"vega-loader": "^4.0.0",
"vega-util": "^1.8.0"
}
}

@@ -5,21 +5,8 @@ # vega-dataflow

Defines a reactive dataflow graph that can process both scalar values and
streaming relational data. A central `Dataflow` instance manages and
schedules a collection of `Operator` instances, each of which is a node in
a dataflow graph. Each operator maintains a local state *value*, and may
also process streaming data objects (or *tuples*) passing through. Operators
may depend on a set of named `Parameters`, which can either be fixed values
or live references to other operator values.
Defines a reactive dataflow graph that can process both scalar values and streaming relational data. A central `Dataflow` instance manages and schedules a collection of `Operator` instances, each of which is a node in a dataflow graph. Each operator maintains a local state *value*, and may also process streaming data objects (or *tuples*) passing through. Operators may depend on a set of named `Parameters`, which can either be fixed values or live references to other operator values.
Upon modifications to operator parameters or input data, changes are
propagated through the graph in topological order. `Pulse` objects propagate
from operators to their dependencies, and carry queues of added, removed
and/or modified tuples.
Upon modifications to operator parameters or input data, changes are propagated through the graph in topological order. `Pulse` objects propagate from operators to their dependencies, and carry queues of added, removed and/or modified tuples.
This module contains only the core reactive dataflow processing engine.
Other modules provide a library of `Operator` types for data stream query
processing, including data generation, sampling, filtering, binning,
aggregation, cross-stream lookup, visual encoding, and spatial layout.
This module contains only the core reactive dataflow processing engine. Other modules provide a library of `Operator` types for data stream query processing, including data generation, sampling, filtering, binning, aggregation, cross-stream lookup, visual encoding, and spatial layout.
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/).
import add from './add';
import connect from './connect';
import events from './events';
import {ingest, request} from './load';
import {ingest, parse, preload, request} from './load';
import on from './on';

@@ -94,2 +94,4 @@ import {rank, rerank} from './rank';

prototype.ingest = ingest;
prototype.parse = parse;
prototype.preload = preload;
prototype.request = request;

@@ -96,0 +98,0 @@

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

import {read} from 'vega-loader';
import {read, responseType} from 'vega-loader';
import {truthy} from 'vega-util';
export const parse = read;
/**

@@ -16,11 +18,55 @@ * Ingests new data into the dataflow. First parses the data using the

export function ingest(target, data, format) {
return this.pulse(target, this.changeset().insert(read(data, format)));
return this.pulse(target, this.changeset().insert(parse(data, format)));
}
/**
* Request data from an external source, parse it, and return a Promise.
* @param {string} url - The URL from which to load the data. This string
* is passed to the vega-loader load method.
* @param {object} [format] - The data format description for parsing
* loaded data. This object is passed to the vega-loader read method.
* @return {Promise} A Promise that resolves upon completion of the request.
* The resolved object contains the following properties:
* - data: an array of parsed data (or null upon error)
* - status: a code for success (0), load fail (-1), or parse fail (-2)
*/
export async function request(url, format) {
const df = this;
let status = 0, data;
try {
data = await df.loader().load(url, {
context: 'dataflow',
response: responseType(format && format.type)
});
try {
data = parse(data, format);
} catch (err) {
status = -2;
df.warn('Data ingestion failed', url, err);
}
} catch (err) {
status = -1;
df.warn('Loading failed', url, err);
}
return {data, status};
}
export async function preload(target, url, format) {
const df = this,
pending = df._pending || loadPending(df);
pending.requests += 1;
const res = await df.request(url, format);
df.pulse(target, df.changeset().remove(truthy).insert(res.data || []));
pending.done();
return res;
}
function loadPending(df) {
var accept, reject,
pending = new Promise(function(a, r) {
accept = function() { a(df); };
reject = r;
});
var pending = new Promise(function(a) { accept = a; }),
accept;

@@ -31,15 +77,4 @@ pending.requests = 0;

if (--pending.requests === 0) {
df.runAfter(function() {
df._pending = null;
try {
df.run();
if (df._pending) {
df._pending.then(accept);
} else {
accept();
}
} catch (err) {
reject(err);
}
});
df._pending = null;
accept(df);
}

@@ -50,42 +85,1 @@ };

}
/**
* Request data from an external source, parse it, and pulse a changeset
* to the specified target operator.
* @param {Operator} target - The Operator to target with the loaded data,
* typically a Collect transform instance.
* @param {string} url - The URL from which to load the data. This string
* is passed to the vega-loader load method.
* @param {object} [format] - The data format description for parsing
* loaded data. This object is passed to the vega-loader read method.
* @return {Promise} A Promise that resolves upon completion of the request.
* Resolves to a status code: 0 success, -1 load fail, -2 parse fail.
*/
export function request(target, url, format) {
var df = this,
status = 0,
pending = df._pending || loadPending(df);
pending.requests += 1;
return df.loader()
.load(url, {context:'dataflow'})
.then(
function(data) {
return read(data, format);
},
function(error) {
status = -1;
df.error('Loading failed', url, error);
})
.catch(
function(error) {
status = -2;
df.error('Data ingestion failed', url, error);
})
.then(function(data) {
df.pulse(target, df.changeset().remove(truthy).insert(data || []));
pending.done();
return status;
});
}

@@ -7,9 +7,6 @@ import {default as Pulse, StopPropagation} from '../Pulse';

/**
* Runs the dataflow. This method will increment the current timestamp
* and process all updated, pulsed and touched operators. When run for
* the first time, all registered operators will be processed. If there
* are pending data loading operations, this method will return immediately
* without evaluating the dataflow. Instead, the dataflow will be
* asynchronously invoked when data loading completes. To track when dataflow
* evaluation completes, use the {@link runAsync} method instead.
* Runs the dataflow and returns a Promise that resolves when the propagation
* cycle completes. This method will increment the current timestamp and
* process all updated, pulsed and touched operators. When run for the first
* time, all registered operators will be processed.
* @param {string} [encode] - The name of an encoding set to invoke during

@@ -19,5 +16,6 @@ * propagation. This value is added to generated Pulse instances;

* This parameter can be used in conjunction with the Encode transform in
* the vega-encode module.
* the vega-encode package.
* @return {Promise} - A promise that resolves to this dataflow.
*/
export function run(encode) {
export async function runAsync(encode) {
var df = this,

@@ -28,17 +26,20 @@ count = 0,

if (df._pending) {
df.info('Awaiting requests, delaying dataflow run.');
return 0;
// if the pulse value is set, this is a re-entrant call
if (df._pulse) {
df.error('Dataflow already running. Use runAsync().then to chain invocations.');
return df;
}
if (df._pulse) {
df.error('Dataflow invoked recursively. Use the runAfter method to queue invocation.');
return 0;
// wait for pending datasets to load
if (df._pending) {
await df._pending;
}
// exit early if there are no updates
if (!df._touched.length) {
df.info('Dataflow invoked, but nothing to do.');
return 0;
return df;
}
// set the current pulse, increment timestamp clock
df._pulse = new Pulse(df, ++df._clock, encode);

@@ -51,3 +52,3 @@

// initialize queue, reset touched operators
// initialize priority queue, reset touched operators
df._touched.forEach(function(op) { df._enqueue(op, true); });

@@ -58,5 +59,6 @@ df._touched = UniqueList(id);

while (df._heap.size() > 0) {
// dequeue operator with highest priority
op = df._heap.pop();
// re-queue if rank changes
// re-queue if rank changed
if (op.rank !== op.qrank) { df._enqueue(op, true); continue; }

@@ -71,6 +73,11 @@

// propagate the pulse
// wait if operator returned a promise
if (next.then) {
next = await next;
}
// propagate evaluation, enqueue dependent operators
if (next !== StopPropagation) {
df._pulse = next;
if (op._targets) op._targets.forEach(function(op) { df._enqueue(op); });
if (op._targets) op._targets.forEach(op => df._enqueue(op));
}

@@ -108,7 +115,7 @@

postrun
.sort(function(a, b) { return b.priority - a.priority; })
.forEach(function(_) { invokeCallback(df, _.callback); });
.sort((a, b) => b.priority - a.priority)
.forEach(_ => invokeCallback(df, _.callback));
}
return this;
return df;
}

@@ -121,14 +128,17 @@

/**
* Runs the dataflow and returns a Promise that resolves when the
* propagation cycle completes. The standard run method may exit early
* if there are pending data loading operations. In contrast, this
* method returns a Promise to allow callers to receive notification
* when dataflow evaluation completes.
* @return {Promise} - A promise that resolves to this dataflow.
* Requests dataflow evaluation and the immediately returns this dataflow
* instance. If there are pending data loading or other asynchronous
* operations, the dataflow will evaluate asynchronously after this method
* has been invoked. To track when dataflow evaluation completes, use the
* {@link runAsync} method instead.
* @param {string} [encode] - The name of an encoding set to invoke during
* propagation. This value is added to generated Pulse instances;
* operators can then respond to (or ignore) this setting as appropriate.
* This parameter can be used in conjunction with the Encode transform in
* the vega-encode module.
* @return {Dataflow} - This dataflow instance.
*/
export function runAsync() {
// return this._pending || Promise.resolve(this.run());
return this._pending
|| (this.run() && this._pending)
|| Promise.resolve(this);
export function run(encode) {
this.runAsync(encode);
return this;
}

@@ -135,0 +145,0 @@

@@ -37,5 +37,10 @@ import Operator from './Operator';

if (rv !== pulse.StopPropagation) this.pulse = rv;
this.stamp = pulse.stamp;
if (rv.then) {
rv = rv.then(_ => this.pulse =_);
} else if (rv !== pulse.StopPropagation) {
this.pulse = rv;
}
return rv;

@@ -42,0 +47,0 @@ };

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