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 3.0.5 to 3.0.6

16

build/vega-dataflow.js

@@ -1023,2 +1023,18 @@ (function (global, factory) {

/**
* Creates a copy of this pulse with new materialized array
* instances for the ADD, REM, MOD, and SOURCE arrays.
* The dataflow, time stamp and field modification values are copied over.
* @return {Pulse} - The cloned pulse instance.
* @see init
*/
prototype$4.clone = function() {
var p = this.fork(ALL);
p.add = p.add.slice();
p.rem = p.rem.slice();
p.mod = p.mod.slice();
if (p.source) p.source = p.source.slice();
return p.materialize(ALL | SOURCE);
};
/**
* Returns a pulse that adds all tuples from a backing source. This is

@@ -1025,0 +1041,0 @@ * useful for cases where operators are added to a dataflow after an

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

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

@@ -131,2 +131,18 @@ import {tupleid} from './Tuple';

/**
* Creates a copy of this pulse with new materialized array
* instances for the ADD, REM, MOD, and SOURCE arrays.
* The dataflow, time stamp and field modification values are copied over.
* @return {Pulse} - The cloned pulse instance.
* @see init
*/
prototype.clone = function() {
var p = this.fork(ALL);
p.add = p.add.slice();
p.rem = p.rem.slice();
p.mod = p.mod.slice();
if (p.source) p.source = p.source.slice();
return p.materialize(ALL | SOURCE);
};
/**
* Returns a pulse that adds all tuples from a backing source. This is

@@ -133,0 +149,0 @@ * useful for cases where operators are added to a dataflow after an

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