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 5.2.0 to 5.2.1

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}async function i(t,n){try{await n(t)}catch(n){t.error(n)}}var s=Symbol("vega_id"),u=1;function a(t){return t[s]}function o(t,n){return t[s]=n,t}function l(t){var n=t===Object(t)?t:{data:t};return a(n)?n:o(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,a=s.length;u<a;++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,o){var h,c,f,d,p,v,g={},m={};for(h=0,c=o.length;h<c;++h)g[a(o[h])]=1;for(h=0,c=e.length;h<c;++h)g[a(p=e[h])]=-1;for(h=0,c=i.length;h<c;++h)d=i[h],o.forEach(function(t){d(t)&&(g[a(t)]=-1)});for(h=0,c=t.length;h<c;++h)v=a(p=t[h]),g[v]?g[v]=1:n.add.push(l(t[h]));for(h=0,c=o.length;h<c;++h)p=o[h],g[a(p)]<0&&n.rem.push(p);function _(t,e,r){r?t[e]=r(t):n.encode=e,u||(m[a(t)]=t)}for(h=0,c=r.length;h<c;++h)p=(f=r[h]).tuple,d=f.field,(v=g[a(p)])>0&&(_(p,d,f.value),n.modifies(d));for(h=0,c=s.length;h<c;++h)f=s[h],d=f.filter,o.forEach(function(t){d(t)&&g[a(t)]>0&&_(t,f.field,f.value)}),n.modifies(f.field);if(u)n.mod=e.length||i.length?o.filter(function(t){return g[a(t)]>0}):o.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],a=s[d];return null!=e&&e>=0?(u[e]!==r||i)&&(u[e]=r,a[e+":"+t]=-1,a[t]=-1):(u!==r||i)&&(s[t]=r,a[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,a,o=this,l=o._argval=o._argval||new p,h=o._argops=o._argops||[],c=[];function f(t,n,r){r instanceof _?(r!==o&&(e&&r.targets().add(o),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!==o&&(t.targets().add(o),c.push(t)):n.error("Pulse parameters must be operator instances.")}),o.source=s;else if(n.isArray(s))for(l.set(i,-1,Array(u=s.length)),a=0;a<u;++a)f(i,a,s[a]);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,a=this._argops;if(a){for(e=0,r=a.length;e<r;++e)s=(i=(n=a[e]).op).modified()&&i.stamp===t,u.set(n.name,n.index,i.value,s);if(a.initonly){for(e=0;e<r;++e)(n=a[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 P={skip:!0};function E(t,e,r,i,s,u){var a,o,l=n.extend({},u,P);n.isFunction(r)||(r=n.constant(r)),void 0===i?a=function(n){t.touch(r(n))}:n.isFunction(i)?(o=new _(null,i,s,!1),a=function(n){var e,i=r(n);o.evaluate(n),c(e=o.value)?t.pulse(i,e,u):t.update(i,e,l)}):a=function(n){t.update(r(n),i,l)},e.apply(a)}function b(t,e,r,i,s,u){var a,o;void 0===i?o=r:(a=n.isFunction(i)?i:n.constant(i),(o=new _(null,i=r?function(t,n){var e=a(t,n);return r.skip()||(r.skip(e!==this.value).value=e),e}:a,s,!1)).modified(u&&u.force),o.rank=e.rank,r&&(o.skip(!0),o.value=r.value,o.targets().add(r),t.connect(r,[o]))),e.targets().add(o)}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[a(t)]=1}),function(t){return e[a(t)]?null:t}}function T(t,n,e,r){var i,s,u,a,o,l=this,h=0;for(this.dataflow=t,this.stamp=n,this.fields=null,this.encode=r||null,this.pulses=e,u=0,a=e.length;u<a;++u)if((i=e[u]).stamp===n){if(i.fields)for(o in s=l.fields||(l.fields={}),i.fields)s[o]=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){var n=[];return{size:()=>n.length,peek:()=>n[0],push:e=>(n.push(e),j(n,0,n.length-1,t)),pop:()=>{var e,r=n.pop();return n.length?(e=n[0],n[0]=r,function(t,n,e){var r,i=n,s=t.length,u=t[n],a=1+(n<<1);for(;a<s;)(r=a+1)<s&&e(t[a],t[r])>=0&&(a=r),t[n]=t[a],a=1+((n=a)<<1);t[n]=u,j(t,i,n,e)}(n,0,t)):e=r,e}}}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(){this.logger(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=U((t,n)=>t.qrank-n.qrank),this._postrun=[]}var G=N.prototype;function W(t){return function(){return this._log[t].apply(this,arguments)}}function B(t,n){_.call(this,t,null,n)}G.stamp=function(){return this._clock},G.loader=function(t){return arguments.length?(this._loader=t,this):this._loader},G.cleanThreshold=1e4,G.add=function(t,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},G.connect=function(t,n){var e,r,i=t.rank;for(e=0,r=n.length;e<r;++e)if(i<n[e].rank)return void this.rerank(t)},G.rank=function(t){t.rank=++this._rank},G.rerank=function(t){for(var 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.")},G.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},G.touch=function(t,n){var e=n||I;return this._pulse?this._enqueue(t):this._touched.add(t),e.skip&&t.skip(!0),this},G.update=function(t,n,e){var r=e||I;return(t.set(n)||r.force)&&this.touch(t,r),this},G.changeset=f,G.ingest=function(t,n,e){return this.pulse(t,this.changeset().insert(O(n,e)))},G.parse=O,G.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},G.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}},G.events=function(t,e,r,i){for(var s,u=this,a=D(r,i),o=function(t){t.dataflow=u;try{a.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,o);return a},G.on=function(t,n,e,r,i){return(t instanceof _?b:E)(this,t,n,e,r,i),this},G.evaluate=async function(t,e,s){const u=this,a=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 o,l,h,c,f=++u._clock,d=0;u._pulse=new M(u,f,t),a>=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;)(o=u._heap.pop()).rank===o.qrank?((l=o.run(u._getPulse(o,t))).then&&(l=await l),a>=n.Debug&&u.debug(o.id,l===q?"STOP":l,o),l!==q&&(u._pulse=l,o._targets&&o._targets.forEach(t=>u._enqueue(t))),++d):u._enqueue(o,!0)}catch(t){c=t}if(u._pulses={},u._pulse=null,a>=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.sort((t,n)=>n.priority-t.priority);u._postrun=[];for(let n=0;n<t.length;++n)await i(u,t[n].callback)}return s&&await i(u,s),u},G.run=function(t,n,e){return this._pulse?z(this):(this.evaluate(t,n,e),this)},G.runAsync=async function(t,n,e){for(;this._running;)await this._running;const r=()=>this._running=null;return(this._running=this.evaluate(t,n,e)).then(r,r),this._running},G.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)}},G._enqueue=function(t,n){var e=!this._pulses[t.id];e&&(this._pulses[t.id]=this._pulse),(e||n)&&(t.qrank=t.rank,this._heap.push(t))},G._getPulse=function(t,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)},G.logger=function(t){return arguments.length?(this._log=t,this):this._log},G.error=W("error"),G.warn=W("warn"),G.info=W("info"),G.debug=W("debug"),G.logLevel=W("level");var H=n.inherits(B,_);H.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},H.evaluate=function(t){var n=this.marshall(t.stamp),e=this.transform(n,t);return n.clear(),e},H.transform=function(){};var J={};function K(t){return t=t&&t.toLowerCase(),J.hasOwnProperty(t)?J[t]:null}t.UniqueList=r,t.asyncCallback=i,t.changeset=f,t.isChangeSet=c,t.Dataflow=N,t.EventStream=k,t.Parameters=p,t.Pulse=M,t.MultiPulse=T,t.Operator=_,t.Transform=B,t.derive=function(t){return h(t,l({}))},t.rederive=h,t.ingest=l,t.isTuple=function(t){return!(!t||!a(t))},t.replace=function(t,n){return o(n,a(t))},t.tupleid=a,t.definition=function(t){var n=K(t);return n&&n.Definition||null},t.transform=K,t.transforms=J,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-util"),require("vega-loader")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-loader"],n):n((t=t||self).vega={},t.vega,t.vega)}(this,function(t,n,e){"use strict";function r(t){var e=t||n.identity,r=[],i={};return r.add=function(t){var n=e(t);return i[n]||(i[n]=1,r.push(t)),r},r.remove=function(t){var n,s=e(t);return i[s]&&(i[s]=0,(n=r.indexOf(t))>=0&&r.splice(n,1)),r},r}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 P={skip:!0};function E(t,e,r,i,s,u){var o,a,l=n.extend({},u,P);n.isFunction(r)||(r=n.constant(r)),void 0===i?o=(n=>t.touch(r(n))):n.isFunction(i)?(a=new _(null,i,s,!1),o=(n=>{a.evaluate(n);const e=r(n),i=a.value;c(i)?t.pulse(e,i,u):t.update(e,i,l)})):o=(n=>t.update(r(n),i,l)),e.apply(o)}function b(t,e,r,i,s,u){if(void 0===i)e.targets().add(r);else{const o=u||{},a=new _(null,function(t,e){return e=n.isFunction(e)?e:n.constant(e),t?function(n,r){const i=e(n,r);return t.skip()||(t.skip(i!==this.value).value=i),i}:e}(r,i),s,!1);a.modified(o.force),a.rank=e.rank,e.targets().add(a),r&&(a.skip(!0),a.value=r.value,a.targets().add(r),t.connect(r,[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){var n=[];return{size:()=>n.length,peek:()=>n[0],push:e=>(n.push(e),j(n,0,n.length-1,t)),pop:()=>{var e,r=n.pop();return n.length?(e=n[0],n[0]=r,function(t,n,e){var r,i=n,s=t.length,u=t[n],o=1+(n<<1);for(;o<s;)(r=o+1)<s&&e(t[o],t[r])>=0&&(o=r),t[n]=t[o],o=1+((n=o)<<1);t[n]=u,j(t,i,n,e)}(n,0,t)):e=r,e}}}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(){this.logger(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=U((t,n)=>t.qrank-n.qrank),this._postrun=[]}var G=N.prototype;function W(t){return function(){return this._log[t].apply(this,arguments)}}function B(t,n){_.call(this,t,null,n)}G.stamp=function(){return this._clock},G.loader=function(t){return arguments.length?(this._loader=t,this):this._loader},G.cleanThreshold=1e4,G.add=function(t,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},G.connect=function(t,n){var e,r,i=t.rank;for(e=0,r=n.length;e<r;++e)if(i<n[e].rank)return void this.rerank(t)},G.rank=function(t){t.rank=++this._rank},G.rerank=function(t){for(var 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.")},G.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},G.touch=function(t,n){var e=n||I;return this._pulse?this._enqueue(t):this._touched.add(t),e.skip&&t.skip(!0),this},G.update=function(t,n,e){var r=e||I;return(t.set(n)||r.force)&&this.touch(t,r),this},G.changeset=f,G.ingest=function(t,n,e){return this.pulse(t,this.changeset().insert(O(n,e)))},G.parse=O,G.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},G.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}},G.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},G.on=function(t,n,e,r,i){return(t instanceof _?b:E)(this,t,n,e,r,i),this},G.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.sort((t,n)=>n.priority-t.priority);u._postrun=[];for(let n=0;n<t.length;++n)await i(u,t[n].callback)}return s&&await i(u,s),u},G.run=function(t,n,e){return this._pulse?z(this):(this.evaluate(t,n,e),this)},G.runAsync=async function(t,n,e){for(;this._running;)await this._running;const r=()=>this._running=null;return(this._running=this.evaluate(t,n,e)).then(r,r),this._running},G.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)}},G._enqueue=function(t,n){var e=!this._pulses[t.id];e&&(this._pulses[t.id]=this._pulse),(e||n)&&(t.qrank=t.rank,this._heap.push(t))},G._getPulse=function(t,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)},G.logger=function(t){return arguments.length?(this._log=t,this):this._log},G.error=W("error"),G.warn=W("warn"),G.info=W("info"),G.debug=W("debug"),G.logLevel=W("level");var H=n.inherits(B,_);H.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},H.evaluate=function(t){var n=this.marshall(t.stamp),e=this.transform(n,t);return n.clear(),e},H.transform=function(){};var J={};function K(t){return t=t&&t.toLowerCase(),J.hasOwnProperty(t)?J[t]:null}t.UniqueList=r,t.asyncCallback=i,t.changeset=f,t.isChangeSet=c,t.Dataflow=N,t.EventStream=k,t.Parameters=p,t.Pulse=M,t.MultiPulse=T,t.Operator=_,t.Transform=B,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=K(t);return n&&n.Definition||null},t.transform=K,t.transforms=J,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "vega-dataflow",
"version": "5.2.0",
"version": "5.2.1",
"description": "Reactive dataflow processing.",

@@ -31,3 +31,3 @@ "keywords": [

},
"gitHead": "c68947ad4822a9ff453bf71a43909189def4854f"
"gitHead": "ae5c7e4449d12aa475a93889fdaf3a1f49dfeece"
}

@@ -45,16 +45,12 @@ import Operator from '../Operator';

if (update === undefined) {
func = function(e) {
df.touch(target(e));
};
func = e => df.touch(target(e));
} else if (isFunction(update)) {
op = new Operator(null, update, params, false);
func = function(e) {
var v, t = target(e);
func = e => {
op.evaluate(e);
isChangeSet(v = op.value) ? df.pulse(t, v, options) : df.update(t, v, opt);
const t = target(e), v = op.value;
isChangeSet(v) ? df.pulse(t, v, options) : df.update(t, v, opt);
};
} else {
func = function(e) {
df.update(target(e), update, opt);
};
func = e => df.update(target(e), update, opt);
}

@@ -66,29 +62,31 @@

function onOperator(df, source, target, update, params, options) {
var func, op;
if (update === undefined) {
op = target;
source.targets().add(target);
} else {
func = isFunction(update) ? update : constant(update);
update = !target ? func : function(_, pulse) {
var value = func(_, pulse);
if (!target.skip()) {
target.skip(value !== this.value).value = value;
}
return value;
};
const opt = options || {},
op = new Operator(null, updater(target, update), params, false);
op.modified(opt.force);
op.rank = source.rank; // immediately follow source
source.targets().add(op); // add dependency
op = new Operator(null, update, params, false);
op.modified(options && options.force);
op.rank = source.rank; // immediately follow source
if (target) {
op.skip(true); // skip first invocation
op.value = target.value;
op.targets().add(target);
df.connect(target, [op]); // rerank as needed, #1672
op.skip(true); // skip first invocation
op.value = target.value; // initialize value
op.targets().add(target); // chain dependencies
df.connect(target, [op]); // rerank as needed, #1672
}
}
}
source.targets().add(op);
function updater(target, update) {
update = isFunction(update) ? update : constant(update);
return target
? function(_, pulse) {
const value = update(_, pulse);
if (!target.skip()) {
target.skip(value !== this.value).value = value;
}
return value;
}
: update;
}

@@ -14,3 +14,3 @@ import {error} from 'vega-util';

* Re-ranks an operator and all downstream target dependencies. This
* is necessary when upstream depencies of higher rank are added to
* is necessary when upstream dependencies of higher rank are added to
* a target operator.

@@ -17,0 +17,0 @@ * @param {Operator} op - The operator to re-rank.

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