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

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.0 to 3.0.1

21

build/vega-dataflow.js

@@ -1061,3 +1061,5 @@ (function (global, factory) {

if (src.fields && !(flags & NO_FIELDS)) p.fields = src.fields;
if (src.fields && !(flags & NO_FIELDS)) {
p.fields = src.fields;
}

@@ -1319,7 +1321,16 @@ if (flags & ADD) {

*/
prototype$5.fork = function() {
if (arguments.length && (arguments[0] & Pulse.prototype.ALL)) {
vegaUtil.error('MultiPulse fork does not support tuple change sets.');
prototype$5.fork = function(flags) {
var p = new Pulse(this.dataflow).init(this, flags & this.NO_FIELDS);
if (flags !== undefined) {
if (flags & p.ADD) {
this.visit(p.ADD, function(t) { return p.add.push(t); });
}
if (flags & p.REM) {
this.visit(p.REM, function(t) { return p.rem.push(t); });
}
if (flags & p.MOD) {
this.visit(p.MOD, function(t) { return p.mod.push(t); });
}
}
return new Pulse(this.dataflow).init(this, 0);
return p;
};

@@ -1326,0 +1337,0 @@

@@ -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,M++)}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,L,{writable:!0,value:{}})}function h(t,n,e,r){this.id=++x,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=++z,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){this.cmp=t,this.nodes=[]}function D(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,D(t,i,n,e)}function O(){this._log=n.logger(),this.logLevel(n.Error),this._clock=0,this._rank=0,this._loader=e.loader(),this._touched=r(n.id),this._pulses={},this._pulse=null,this._heap=new A(function(t,n){return t.qrank-n.qrank}),this._postrun=[]}function q(t){return function(){return this._log[t].apply(this,arguments)}}function E(t,n){h.call(this,t,null,n)}function b(t){return t=t&&t.toLowerCase(),K.hasOwnProperty(t)?K[t]:null}var S=Symbol("vega_id"),M=1,L="_:mod:_",R=f.prototype;R.set=function(t,e,r,i){var s=this,u=s[t],o=s[L];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},R.modified=function(t,e){var r,i=this[L];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]},R.clear=function(){return this[L]={},this};var x=0,T=new f,C=h.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=c(1),C.modified=c(2),C.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},C.marshall=function(t){var n,e,r,i,s,u=this._argval||T,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 z=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},I={},N=_.prototype;N.StopPropagation=I,N.ADD=1,N.REM=2,N.MOD=4,N.ADD_REM=3,N.ADD_MOD=5,N.ALL=7,N.REFLOW=8,N.SOURCE=16,N.NO_SOURCE=32,N.NO_FIELDS=64,N.fork=function(t){return new _(this.dataflow).init(this,t)},N.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},N.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},N.runAfter=function(t){this.dataflow.runAfter(t)},N.changed=function(t){var n=t||7;return 1&n&&this.add.length||2&n&&this.rem.length||4&n&&this.mod.length},N.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},N.modifies=function(t){var e=n.array(t),r=this.fields||(this.fields={});return e.forEach(function(t){r[t]=!0}),this},N.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)},N.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},N.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},N.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 G=n.inherits(w,_);G.fork=function(){return arguments.length&&arguments[0]&_.prototype.ALL&&n.error("MultiPulse fork does not support tuple change sets."),new _(this.dataflow).init(this,0)},G.changed=function(t){return this.changes&t},G.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},G.filter=function(){n.error("MultiPulse does not support filtering.")},G.materialize=function(){n.error("MultiPulse does not support materialization.")},G.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 W={skip:!1,force:!1},B=A.prototype;B.size=function(){return this.nodes.length},B.clear=function(){return this.nodes=[],this},B.peek=function(){return this.nodes[0]},B.push=function(t){var n=this.nodes;return n.push(t),D(n,0,n.length-1,this.cmp)},B.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},B.replace=function(t){var n=this.nodes,e=n[0];return n[0]=t,P(n,0,this.cmp),e},B.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 H=O.prototype;H.stamp=function(){return this._clock},H.loader=function(t){return arguments.length?(this._loader=t,this):this._loader},H.cleanThreshold=1e4,H.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},H.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)},H.rank=function(t){t.rank=++this._rank},H.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;--r>=0;)i.push(n=e[r]),n===t&&this.error("Cycle detected in dataflow graph.")},H.pulse=function(t,n,e){this.touch(t,e||W);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},H.touch=function(t,n){var e=n||W;return this._pulse?this._enqueue(t):this._touched.add(t),e.skip&&t.skip(!0),this},H.update=function(t,n,e){var r=e||W;return(t.set(n)||r.force)&&this.touch(t,r),this},H.changeset=l,H.ingest=function(t,n,r){return this.pulse(t,this.changeset().insert(e.read(n,r)))},H.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)},H.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},H.on=function(t,n,e,r,i){return(t instanceof h?m:g)(this,t,n,e,r,i),this},H.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===I?"STOP":i,e),i!==I&&(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.forEach(function(t){try{t(o)}catch(t){o.error(t)}})}return a},H.runAsync=function(){return this._pending||Promise.resolve(this.run())},H.runAfter=function(t,n){if(this._pulse||n)this._postrun.push(t);else try{t(this)}catch(t){this.error(t)}},H._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))},H._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)):(i=i&&i.pulse,r=this._pulses[t.id],i&&i!==I&&(i.stamp===s&&r.target!==t?r=i:r.source=i.source),r)},H.error=q("error"),H.warn=q("warn"),H.info=q("info"),H.debug=q("debug"),H.logLevel=q("level");var J=n.inherits(E,h);J.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},J.evaluate=function(t){var n=this.marshall(t.stamp),e=this.transform(n,t);return n.clear(),e},J.transform=function(){};var K={};t.UniqueList=r,t.changeset=l,t.isChangeSet=a,t.Dataflow=O,t.EventStream=d,t.Parameters=f,t.Pulse=_,t.MultiPulse=w,t.Operator=h,t.Transform=E,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=b(t);return n&&n.Definition||null},t.transform=b,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.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[b]}function s(t,n){return t[b]=n,t}function u(t){var n=t===Object(t)?t:{data:t};return i(n)?n:s(n,S++)}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 h(t,e,r){r?t[e]=r(t):n.encode=e,a||(f[i(t)]=t)}var f,c,d,p,v,g,m;for(c=0,d=t.length;c<d;++c)n.add.push(u(t[c]));for(f={},c=0,d=e.length;c<d;++c)f[i(g=e[c])]=g;for(c=0,d=s.length;c<d;++c)v=s[c],l.forEach(function(t){v(t)&&(f[i(t)]=t)});for(m in f)n.rem.push(f[m]);for(f={},c=0,d=r.length;c<d;++c)h((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)&&h(t,p.field,p.value)}),n.modifies(p.field);if(a)n.mod=e.length||s.length?l.filter(function(t){return f.hasOwnProperty(i(t))}):l.slice();else for(m in f)n.mod.push(f[m]);return n}}}function h(){Object.defineProperty(this,L,{writable:!0,value:{}})}function f(t,n,e,r){this.id=++x,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=++z,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,h=n.extend({},u,U);n.isFunction(r)||(r=n.constant(r)),void 0===i?o=function(n){t.touch(r(n))}:n.isFunction(i)?(l=new f(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,h)}):o=function(n){t.update(r(n),i,h)},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 f(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,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){s=l.fields||(l.fields={});for(a in 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}function A(t){this.cmp=t,this.nodes=[]}function D(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 O(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,D(t,i,n,e)}function P(){this._log=n.logger(),this.logLevel(n.Error),this._clock=0,this._rank=0,this._loader=e.loader(),this._touched=r(n.id),this._pulses={},this._pulse=null,this._heap=new A(function(t,n){return t.qrank-n.qrank}),this._postrun=[]}function E(t){return function(){return this._log[t].apply(this,arguments)}}function q(t,n){f.call(this,t,null,n)}function M(t){return t=t&&t.toLowerCase(),K.hasOwnProperty(t)?K[t]:null}var b=Symbol("vega_id"),S=1,L="_:mod:_",R=h.prototype;R.set=function(t,e,r,i){var s=this,u=s[t],o=s[L];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},R.modified=function(t,e){var r,i=this[L];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]},R.clear=function(){return this[L]={},this};var x=0,T=new h,C=f.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=c(1),C.modified=c(2),C.parameters=function(t,e){function r(t,n,r){r instanceof f?(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 h,c=a._argops=a._argops||[],d=[];for(i in t)if(s=t[i],"pulse"===i)n.array(s).forEach(function(t){t instanceof f?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||T,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 z=0,I=d.prototype;I._filter=n.truthy,I._apply=n.identity,I.targets=function(){return this._targets||(this._targets=r(n.id))},I.consume=function(t){return arguments.length?(this._consume=!!t,this):!!this._consume},I.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())}},I.filter=function(t){var n=p(t);return this.targets().add(n),n},I.apply=function(t){var n=p(null,t);return this.targets().add(n),n},I.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},I.throttle=function(t){var n=-1;return this.filter(function(){var e=Date.now();return e-n>t?(n=e,1):0})},I.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},I.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 U={skip:!0},j={},N=_.prototype;N.StopPropagation=j,N.ADD=1,N.REM=2,N.MOD=4,N.ADD_REM=3,N.ADD_MOD=5,N.ALL=7,N.REFLOW=8,N.SOURCE=16,N.NO_SOURCE=32,N.NO_FIELDS=64,N.fork=function(t){return new _(this.dataflow).init(this,t)},N.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},N.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},N.runAfter=function(t){this.dataflow.runAfter(t)},N.changed=function(t){var n=t||7;return 1&n&&this.add.length||2&n&&this.rem.length||4&n&&this.mod.length},N.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},N.modifies=function(t){var e=n.array(t),r=this.fields||(this.fields={});return e.forEach(function(t){r[t]=!0}),this},N.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)},N.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},N.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},N.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 G=n.inherits(w,_);G.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},G.changed=function(t){return this.changes&t},G.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},G.filter=function(){n.error("MultiPulse does not support filtering.")},G.materialize=function(){n.error("MultiPulse does not support materialization.")},G.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 W={skip:!1,force:!1},B=A.prototype;B.size=function(){return this.nodes.length},B.clear=function(){return this.nodes=[],this},B.peek=function(){return this.nodes[0]},B.push=function(t){var n=this.nodes;return n.push(t),D(n,0,n.length-1,this.cmp)},B.pop=function(){var t,n=this.nodes,e=n.pop();return n.length?(t=n[0],n[0]=e,O(n,0,this.cmp)):t=e,t},B.replace=function(t){var n=this.nodes,e=n[0];return n[0]=t,O(n,0,this.cmp),e},B.pushpop=function(t){var n=this.nodes,e=n[0];return n.length&&this.cmp(e,t)<0&&(n[0]=t,t=e,O(n,0,this.cmp)),t};var H=P.prototype;H.stamp=function(){return this._clock},H.loader=function(t){return arguments.length?(this._loader=t,this):this._loader},H.cleanThreshold=1e4,H.add=function(t,e,r,i){var s,u=1;return t instanceof f?s=t:t&&t.prototype instanceof f?s=new t:n.isFunction(t)?s=new f(null,t):(u=0,s=new f(t,e)),this.rank(s),u&&(i=r,r=e),r&&this.connect(s,s.parameters(r,i)),this.touch(s),s},H.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)},H.rank=function(t){t.rank=++this._rank},H.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;--r>=0;)i.push(n=e[r]),n===t&&this.error("Cycle detected in dataflow graph.")},H.pulse=function(t,n,e){this.touch(t,e||W);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},H.touch=function(t,n){var e=n||W;return this._pulse?this._enqueue(t):this._touched.add(t),e.skip&&t.skip(!0),this},H.update=function(t,n,e){var r=e||W;return(t.set(n)||r.force)&&this.touch(t,r),this},H.changeset=l,H.ingest=function(t,n,r){return this.pulse(t,this.changeset().insert(e.read(n,r)))},H.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)},H.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},H.on=function(t,n,e,r,i){return(t instanceof f?m:g)(this,t,n,e,r,i),this},H.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===j?"STOP":i,e),i!==j&&(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 h=o._postrun;o._postrun=[],h.forEach(function(t){try{t(o)}catch(t){o.error(t)}})}return a},H.runAsync=function(){return this._pending||Promise.resolve(this.run())},H.runAfter=function(t,n){if(this._pulse||n)this._postrun.push(t);else try{t(this)}catch(t){this.error(t)}},H._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))},H._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)):(i=i&&i.pulse,r=this._pulses[t.id],i&&i!==j&&(i.stamp===s&&r.target!==t?r=i:r.source=i.source),r)},H.error=E("error"),H.warn=E("warn"),H.info=E("info"),H.debug=E("debug"),H.logLevel=E("level");var J=n.inherits(q,f);J.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},J.evaluate=function(t){var n=this.marshall(t.stamp),e=this.transform(n,t);return n.clear(),e},J.transform=function(){};var K={};t.UniqueList=r,t.changeset=l,t.isChangeSet=a,t.Dataflow=P,t.EventStream=d,t.Parameters=h,t.Pulse=_,t.MultiPulse=w,t.Operator=f,t.Transform=q,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=K,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "vega-dataflow",
"version": "3.0.0",
"version": "3.0.1",
"description": "Reactive dataflow processing.",

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

@@ -51,7 +51,16 @@ import Pulse from './Pulse';

*/
prototype.fork = function() {
if (arguments.length && (arguments[0] & Pulse.prototype.ALL)) {
error('MultiPulse fork does not support tuple change sets.');
prototype.fork = function(flags) {
var p = new Pulse(this.dataflow).init(this, flags & this.NO_FIELDS);
if (flags !== undefined) {
if (flags & p.ADD) {
this.visit(p.ADD, function(t) { return p.add.push(t); });
}
if (flags & p.REM) {
this.visit(p.REM, function(t) { return p.rem.push(t); });
}
if (flags & p.MOD) {
this.visit(p.MOD, function(t) { return p.mod.push(t); });
}
}
return new Pulse(this.dataflow).init(this, 0);
return p;
};

@@ -58,0 +67,0 @@

@@ -169,3 +169,5 @@ import {tupleid} from './Tuple';

if (src.fields && !(flags & NO_FIELDS)) p.fields = src.fields;
if (src.fields && !(flags & NO_FIELDS)) {
p.fields = src.fields;
}

@@ -172,0 +174,0 @@ if (flags & ADD) {

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