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 5.0.0 to 5.1.0

src/util/asyncCallback.js

2

build/vega-dataflow.min.js

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

!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})});
!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}async function i(t,n){try{await n(t)}catch(n){t.error(n)}}var s=Symbol("vega_id"),u=1;function o(t){return t[s]}function a(t,n){return t[s]=n,t}function l(t){var n=t===Object(t)?t:{data:t};return o(n)?n:a(n,u++)}function h(t,n){for(var e in t)n[e]=t[e];return n}function c(t){return t&&t.constructor===f}function f(){var t=[],e=[],r=[],i=[],s=[],u=!1;return{constructor:f,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 u=!0,this},pulse:function(n,a){var h,c,f,d,p,v,g={},m={};for(h=0,c=a.length;h<c;++h)g[o(a[h])]=1;for(h=0,c=e.length;h<c;++h)g[o(p=e[h])]=-1;for(h=0,c=i.length;h<c;++h)d=i[h],a.forEach(function(t){d(t)&&(g[o(t)]=-1)});for(h=0,c=t.length;h<c;++h)v=o(p=t[h]),g[v]?g[v]=1:n.add.push(l(t[h]));for(h=0,c=a.length;h<c;++h)p=a[h],g[o(p)]<0&&n.rem.push(p);function _(t,e,r){r?t[e]=r(t):n.encode=e,u||(m[o(t)]=t)}for(h=0,c=r.length;h<c;++h)p=(f=r[h]).tuple,d=f.field,(v=g[o(p)])>0&&(_(p,d,f.value),n.modifies(d));for(h=0,c=s.length;h<c;++h)f=s[h],d=f.filter,a.forEach(function(t){d(t)&&g[o(t)]>0&&_(t,f.field,f.value)}),n.modifies(f.field);if(u)n.mod=e.length||i.length?a.filter(function(t){return g[o(t)]>0}):a.slice();else for(v in m)n.mod.push(m[v]);return n}}}var d="_:mod:_";function p(){Object.defineProperty(this,d,{writable:!0,value:{}})}var v=p.prototype;v.set=function(t,e,r,i){var s=this,u=s[t],o=s[d];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},v.modified=function(t,e){var r,i=this[d];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]},v.clear=function(){return this[d]={},this};var g=0,m=new p;function _(t,n,e,r){this.id=++g,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 y=_.prototype;function w(t){return function(n){var e=this.flags;return 0===arguments.length?!!(e&t):(this.flags=n?e|t:e&~t,this)}}y.targets=function(){return this._targets||(this._targets=r(n.id))},y.set=function(t){return this.value!==t?(this.value=t,1):0},y.skip=w(1),y.modified=w(2),y.parameters=function(t,e,r){e=!1!==e;var i,s,u,o,a=this,l=a._argval=a._argval||new p,h=a._argops=a._argops||[],c=[];function f(t,n,r){r instanceof _?(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 _?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},y.marshall=function(t){var n,e,r,i,s,u=this._argval||m,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},y.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}},y.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 F=0;function k(t,n,e){this.id=++F,this.value=null,e&&(this.receive=e),t&&(this._filter=t),n&&(this._apply=n)}function D(t,n,e){return new k(t,n,e)}var A=k.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=D(t);return this.targets().add(n),n},A.apply=function(t){var n=D(null,t);return this.targets().add(n),n},A.merge=function(){var t=D();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=D();return this.targets().add(D(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(D(null,null,function(){e=!0})),n.targets().add(D(null,null,function(){e=!1})),this.filter(function(){return e})};const O=e.read;var E={skip:!0};function P(t,e,r,i,s,u){var o,a,l=n.extend({},u,E);n.isFunction(r)||(r=n.constant(r)),void 0===i?o=function(n){t.touch(r(n))}:n.isFunction(i)?(a=new _(null,i,s,!1),o=function(n){var e,i=r(n);a.evaluate(n),c(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 b(t,e,r,i,s,u){var o,a;void 0===i?a=r:(o=n.isFunction(i)?i:n.constant(i),(a=new _(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 M(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 S=M.prototype;function L(t,n){return t?function(e,r){return t(e,r)&&n(e,r)}:n}function R(t,e){var r=[];return n.visitArray(t,e,function(t){r.push(t)}),r}function x(t,n){var e={};return t.visit(n,function(t){e[o(t)]=1}),function(t){return e[o(t)]?null:t}}function T(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}S.StopPropagation=q,S.ADD=1,S.REM=2,S.MOD=4,S.ADD_REM=3,S.ADD_MOD=5,S.ALL=7,S.REFLOW=8,S.SOURCE=16,S.NO_SOURCE=32,S.NO_FIELDS=64,S.fork=function(t){return new M(this.dataflow).init(this,t)},S.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)},S.addAll=function(){var t=this;return this.source&&this.source.length!==this.add.length?((t=new M(this.dataflow).init(this)).add=t.source,t):t},S.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},S.runAfter=function(t){this.dataflow.runAfter(t)},S.changed=function(t){var n=t||7;return 1&n&&this.add.length||2&n&&this.rem.length||4&n&&this.mod.length},S.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,x(this,1))),this},S.modifies=function(t){var e=n.array(t),r=this.fields||(this.fields={});return e.forEach(function(t){r[t]=!0}),this},S.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)},S.filter=function(t,n){var e=this;return 1&t&&(e.addF=L(e.addF,n)),2&t&&(e.remF=L(e.remF,n)),4&t&&(e.modF=L(e.modF,n)),16&t&&(e.srcF=L(e.srcF,n)),e},S.materialize=function(t){var n=this;return 1&(t=t||7)&&n.addF&&(n.add=R(n.add,n.addF),n.addF=null),2&t&&n.remF&&(n.rem=R(n.rem,n.remF),n.remF=null),4&t&&n.modF&&(n.mod=R(n.mod,n.modF),n.modF=null),16&t&&n.srcF&&(n.source=n.source.filter(n.srcF),n.srcF=null),n},S.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,x(s,5),u):n.visitArray(r,s.srcF,u))),s)};var C=n.inherits(T,M);function z(t){return t.error("Dataflow already running. Use runAsync() to chain invocations."),t}C.fork=function(t){var n=new M(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},C.changed=function(t){return this.changes&t},C.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},C.filter=function(){n.error("MultiPulse does not support filtering.")},C.materialize=function(){n.error("MultiPulse does not support materialization.")},C.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 I={skip:!1,force:!1};function U(t){this.cmp=t,this.nodes=[]}var j=U.prototype;function N(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 G(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,N(t,i,n,e)}function W(){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 U(function(t,n){return t.qrank-n.qrank}),this._postrun=[]}j.size=function(){return this.nodes.length},j.clear=function(){return this.nodes=[],this},j.peek=function(){return this.nodes[0]},j.push=function(t){var n=this.nodes;return n.push(t),N(n,0,n.length-1,this.cmp)},j.pop=function(){var t,n=this.nodes,e=n.pop();return n.length?(t=n[0],n[0]=e,G(n,0,this.cmp)):t=e,t},j.replace=function(t){var n=this.nodes,e=n[0];return n[0]=t,G(n,0,this.cmp),e},j.pushpop=function(t){var n=this.nodes,e=n[0];return n.length&&this.cmp(e,t)<0&&(n[0]=t,t=e,G(n,0,this.cmp)),t};var B=W.prototype;function H(t){return function(){return this._log[t].apply(this,arguments)}}function J(t,n){_.call(this,t,null,n)}B.stamp=function(){return this._clock},B.loader=function(t){return arguments.length?(this._loader=t,this):this._loader},B.cleanThreshold=1e4,B.add=function(t,e,r,i){var s,u=1;return t instanceof _?s=t:t&&t.prototype instanceof _?s=new t:n.isFunction(t)?s=new _(null,t):(u=0,s=new _(t,e)),this.rank(s),u&&(i=r,r=e),r&&this.connect(s,s.parameters(r,i)),this.touch(s),s},B.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)},B.rank=function(t){t.rank=++this._rank},B.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.")},B.pulse=function(t,n,e){this.touch(t,e||I);var r=new M(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},B.touch=function(t,n){var e=n||I;return this._pulse?this._enqueue(t):this._touched.add(t),e.skip&&t.skip(!0),this},B.update=function(t,n,e){var r=e||I;return(t.set(n)||r.force)&&this.touch(t,r),this},B.changeset=f,B.ingest=function(t,n,e){return this.pulse(t,this.changeset().insert(O(n,e)))},B.parse=O,B.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},B.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=O(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}},B.events=function(t,e,r,i){for(var s,u=this,o=D(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},B.on=function(t,n,e,r,i){return(t instanceof _?b:P)(this,t,n,e,r,i),this},B.evaluate=async function(t,e,s){const u=this,o=u.logLevel();if(u._pulse)return z(u);if(u._pending&&await u._pending,e&&await i(u,e),!u._touched.length)return u.info("Dataflow invoked, but nothing to do."),u;let a,l,h,c,f=++u._clock,d=0;u._pulse=new M(u,f,t),o>=n.Info&&(h=Date.now(),u.debug("-- START PROPAGATION ("+f+") -----")),u._touched.forEach(function(t){u._enqueue(t,!0)}),u._touched=r(n.id);try{for(;u._heap.size()>0;)(a=u._heap.pop()).rank===a.qrank?((l=a.run(u._getPulse(a,t))).then&&(l=await l),o>=n.Debug&&u.debug(a.id,l===q?"STOP":l,a),l!==q&&(u._pulse=l,a._targets&&a._targets.forEach(t=>u._enqueue(t))),++d):u._enqueue(a,!0)}catch(t){c=t}if(u._pulses={},u._pulse=null,o>=n.Info&&(h=Date.now()-h,u.info("> Pulse "+f+": "+d+" operators; "+h+"ms")),c&&(u._postrun=[],u.error(c)),u._postrun.length){const t=u._postrun;u._postrun=[],t.sort((t,n)=>n.priority-t.priority).forEach(async function(t){await i(u,t.callback)})}return s&&await i(u,s),u},B.run=function(t,n,e){return this._pulse?z(this):(this.evaluate(t,n,e),this)},B.runAsync=async function(t,n,e){for(;this._running;)await this._running;return(this._running=this.evaluate(t,n,e)).then(()=>this._running=null),this._running},B.runAfter=function(t,n,e){if(this._pulse||n)this._postrun.push({priority:e||0,callback:t});else try{t(this)}catch(t){this.error(t)}},B._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))},B._getPulse=function(t,e){var r,i=t.source,s=this._clock;return i&&n.isArray(i)?new T(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)},B.error=H("error"),B.warn=H("warn"),B.info=H("info"),B.debug=H("debug"),B.logLevel=H("level");var K=n.inherits(J,_);K.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},K.evaluate=function(t){var n=this.marshall(t.stamp),e=this.transform(n,t);return n.clear(),e},K.transform=function(){};var Q={};function V(t){return t=t&&t.toLowerCase(),Q.hasOwnProperty(t)?Q[t]:null}t.UniqueList=r,t.asyncCallback=i,t.changeset=f,t.isChangeSet=c,t.Dataflow=W,t.EventStream=k,t.Parameters=p,t.Pulse=M,t.MultiPulse=T,t.Operator=_,t.Transform=J,t.derive=function(t){return h(t,l({}))},t.rederive=h,t.ingest=l,t.isTuple=function(t){return!(!t||!o(t))},t.replace=function(t,n){return a(n,o(t))},t.tupleid=o,t.definition=function(t){var n=V(t);return n&&n.Definition||null},t.transform=V,t.transforms=Q,Object.defineProperty(t,"__esModule",{value:!0})});
// Utilities
export {default as UniqueList} from './src/util/UniqueList';
export {default as asyncCallback} from './src/util/asyncCallback';

@@ -4,0 +5,0 @@ // Core Runtime

{
"name": "vega-dataflow",
"version": "5.0.0",
"version": "5.1.0",
"description": "Reactive dataflow processing.",

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

@@ -7,3 +7,3 @@ import add from './add';

import {rank, rerank} from './rank';
import {run, runAsync, runAfter, enqueue, getPulse} from './run';
import {evaluate, run, runAsync, runAfter, enqueue, getPulse} from './run';
import {pulse, touch, update} from './update';

@@ -104,2 +104,3 @@ import changeset from '../ChangeSet';

// PULSE PROPAGATION
prototype.evaluate = evaluate;
prototype.run = run;

@@ -106,0 +107,0 @@ prototype.runAsync = runAsync;

import {default as Pulse, StopPropagation} from '../Pulse';
import MultiPulse from '../MultiPulse';
import asyncCallback from '../util/asyncCallback';
import UniqueList from '../util/UniqueList';

@@ -7,6 +8,8 @@ import {id, isArray, Info, Debug} from 'vega-util';

/**
* 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.
* Evaluates the dataflow and returns a Promise that resolves when pulse
* propagation completes. This method will increment the current timestamp
* and process all updated, pulsed and touched operators. When invoked for
* the first time, all registered operators will be processed. This method
* should not be invoked by third-party clients, use {@link runAsync} or
* {@link run} instead.
* @param {string} [encode] - The name of an encoding set to invoke during

@@ -17,15 +20,16 @@ * propagation. This value is added to generated Pulse instances;

* the vega-encode package.
* @return {Promise} - A promise that resolves to this dataflow.
* @param {function} [prerun] - An optional callback function to invoke
* immediately before dataflow evaluation commences.
* @param {function} [postrun] - An optional callback function to invoke
* after dataflow evaluation completes. The callback will be invoked
* after those registered via {@link runAfter}.
* @return {Promise} - A promise that resolves to this dataflow after
* evaluation completes.
*/
export async function runAsync(encode) {
var df = this,
count = 0,
level = df.logLevel(),
op, next, dt, error;
export async function evaluate(encode, prerun, postrun) {
const df = this,
level = df.logLevel();
// 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) return reentrant(df);

@@ -37,2 +41,5 @@ // wait for pending datasets to load

// invoke prerun function, if provided
if (prerun) await asyncCallback(df, prerun);
// exit early if there are no updates

@@ -44,8 +51,12 @@ if (!df._touched.length) {

// set the current pulse, increment timestamp clock
df._pulse = new Pulse(df, ++df._clock, encode);
// increment timestamp clock
let stamp = ++df._clock,
count = 0, op, next, dt, error;
// set the current pulse
df._pulse = new Pulse(df, stamp, encode);
if (level >= Info) {
dt = Date.now();
df.debug('-- START PROPAGATION (' + df._clock + ') -----');
df.debug('-- START PROPAGATION (' + stamp + ') -----');
}

@@ -68,2 +79,7 @@

// await if operator returned a promise
if (next.then) {
next = await next;
}
if (level >= Debug) {

@@ -73,7 +89,2 @@ df.debug(op.id, next === StopPropagation ? 'STOP' : next, op);

// wait if operator returned a promise
if (next.then) {
next = await next;
}
// propagate evaluation, enqueue dependent operators

@@ -98,3 +109,3 @@ if (next !== StopPropagation) {

dt = Date.now() - dt;
df.info('> Pulse ' + df._clock + ': ' + count + ' operators; ' + dt + 'ms');
df.info('> Pulse ' + stamp + ': ' + count + ' operators; ' + dt + 'ms');
}

@@ -107,20 +118,46 @@

if (df._onrun) {
try { df._onrun(df, count, error); } catch (err) { df.error(err); }
}
// invoke callbacks queued via runAfter
if (df._postrun.length) {
var postrun = df._postrun;
const pr = df._postrun;
df._postrun = [];
postrun
.sort((a, b) => b.priority - a.priority)
.forEach(_ => invokeCallback(df, _.callback));
pr.sort((a, b) => b.priority - a.priority)
.forEach(async function(_) {
await asyncCallback(df, _.callback);
});
}
// invoke postrun function, if provided
if (postrun) await asyncCallback(df, postrun);
return df;
}
function invokeCallback(df, callback) {
try { callback(df); } catch (err) { df.error(err); }
/**
* Queues dataflow evaluation to run once any other queued evaluations have
* completed and returns a Promise that resolves when the queued pulse
* propagation completes. If provided, a callback function will be invoked
* immediately before evaluation commences. This method will ensure a
* separate evaluation is invoked for each time it is called.
* @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 package.
* @param {function} [prerun] - An optional callback function to invoke
* immediately before dataflow evaluation commences.
* @param {function} [postrun] - An optional callback function to invoke
* after dataflow evaluation completes. The callback will be invoked
* after those registered via {@link runAfter}.
* @return {Promise} - A promise that resolves to this dataflow after
* evaluation completes.
*/
export async function runAsync(encode, prerun, postrun) {
// await previously queued functions
while (this._running) await this._running;
// run dataflow, manage running promise
(this._running = this.evaluate(encode, prerun, postrun))
.then(() => this._running = null);
return this._running;
}

@@ -133,3 +170,4 @@

* has been invoked. To track when dataflow evaluation completes, use the
* {@link runAsync} method instead.
* {@link runAsync} method instead. This method will raise an error if
* invoked while the dataflow is already in the midst of evaluation.
* @param {string} [encode] - The name of an encoding set to invoke during

@@ -140,7 +178,12 @@ * propagation. This value is added to generated Pulse instances;

* the vega-encode module.
* @param {function} [prerun] - An optional callback function to invoke
* immediately before dataflow evaluation commences.
* @param {function} [postrun] - An optional callback function to invoke
* after dataflow evaluation completes. The callback will be invoked
* after those registered via {@link runAfter}.
* @return {Dataflow} - This dataflow instance.
*/
export function run(encode) {
this.runAsync(encode);
return this;
export function run(encode, prerun, postrun) {
return this._pulse ? reentrant(this)
: (this.evaluate(encode, prerun, postrun), this);
}

@@ -151,3 +194,8 @@

* propagation completes. If no propagation is currently occurring,
* the function is invoked immediately.
* the function is invoked immediately. Callbacks scheduled via runAfter
* are invoked immediately upon completion of the current cycle, before
* any request queued via runAsync. This method is primarily intended for
* internal use. Third-party callers using runAfter to schedule a callback
* that invokes {@link run} or {@link runAsync} should not use this method,
* but instead use {@link runAsync} with prerun or postrun arguments.
* @param {function(Dataflow)} callback - The callback function to run.

@@ -160,2 +208,5 @@ * The callback will be invoked with this Dataflow instance as its

* currently occurring.
* @param {number} [priority] - A priority value used to sort registered
* callbacks to determine execution order. This argument is intended
* for internal Vega use only.
*/

@@ -171,3 +222,3 @@ export function runAfter(callback, enqueue, priority) {

// pulse propagation already complete, invoke immediately
invokeCallback(this, callback);
try { callback(this); } catch (err) { this.error(err); }
}

@@ -177,2 +228,10 @@ }

/**
* Raise an error for re-entrant dataflow evaluation.
*/
function reentrant(df) {
df.error('Dataflow already running. Use runAsync() to chain invocations.');
return df;
}
/**
* Enqueue an operator into the priority queue for evaluation. The operator

@@ -179,0 +238,0 @@ * will be enqueued if it has no registered pulse for the current cycle, or if

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