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.4.1 to 5.5.0

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 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.pulse=n||t);var n};var k=0;function F(t,n,e){this.id=++k,this.value=null,e&&(this.receive=e),t&&(this._filter=t),n&&(this._apply=n)}function A(t,n,e){return new F(t,n,e)}var D=F.prototype;D._filter=n.truthy,D._apply=n.identity,D.targets=function(){return this._targets||(this._targets=r(n.id))},D.consume=function(t){return arguments.length?(this._consume=!!t,this):!!this._consume},D.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())}},D.filter=function(t){var n=A(t);return this.targets().add(n),n},D.apply=function(t){var n=A(null,t);return this.targets().add(n),n},D.merge=function(){var t=A();this.targets().add(t);for(var n=0,e=arguments.length;n<e;++n)arguments[n].targets().add(t);return t},D.throttle=function(t){var n=-1;return this.filter((function(){var e=Date.now();return e-n>t?(n=e,1):0}))},D.debounce=function(t){var e=A();return this.targets().add(A(null,null,n.debounce(t,(function(t){var n=t.dataflow;e.receive(t),n&&n.run&&n.run()})))),e},D.between=function(t,n){var e=!1;return t.targets().add(A(null,null,(function(){e=!0}))),n.targets().add(A(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 C(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=this.fields||(this.fields={});return n.isArray(t)?t.forEach(t=>e[t]=!0):e[t]=!0,this},S.modified=function(t,e){var r=this.fields;return!(!e&&!this.mod.length||!r)&&(arguments.length?n.isArray(t)?t.some((function(t){return r[t]})):r[t]:!!r)},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 T=n.inherits(C,M);function z(t){return t.error("Dataflow already running. Use runAsync() to chain invocations."),t}T.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},T.changed=function(t){return this.changes&t},T.modified=function(t){var e=this,r=e.fields;return r&&e.changes&e.MOD?n.isArray(t)?t.some((function(t){return r[t]})):r[t]:0},T.filter=function(){n.error("MultiPulse does not support filtering.")},T.materialize=function(){n.error("MultiPulse does not support materialization.")},T.visit=function(t,n){var e=this,r=e.pulses,i=r.length,s=0;if(t&e.SOURCE)for(;s<i;++s)r[s].visit(t,n);else for(;s<i;++s)r[s].stamp===e.stamp&&r[s].visit(t,n);return e};var I={skip:!1,force:!1};function U(t){var n=[];return{clear:()=>n=[],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._input={},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._input[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=A(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(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&&a._targets&&a._targets.forEach(t=>u._enqueue(t)),++d):u._enqueue(a,!0)}catch(t){u._heap.clear(),c=t}if(u._input={},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=t.stamp<this._clock;e&&(t.stamp=this._clock),(e||n)&&(t.qrank=t.rank,this._heap.push(t))},G._getPulse=function(t,e){var r=t.source,i=this._clock;return r&&n.isArray(r)?new C(this,i,r.map(t=>t.pulse),e):this._input[t.id]||function(t,n){if(n&&n.stamp===t.stamp)return n;t=t.fork(),n&&n!==q&&(t.source=n.source);return t}(this._pulse,r&&r.pulse)},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).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(),n.hasOwnProperty(J,t)?J[t]:null}t.Dataflow=N,t.EventStream=F,t.MultiPulse=C,t.Operator=_,t.Parameters=p,t.Pulse=M,t.Transform=B,t.UniqueList=r,t.asyncCallback=i,t.changeset=f,t.definition=function(t){var n=K(t);return n&&n.Definition||null},t.derive=function(t){return h(t,l({}))},t.ingest=l,t.isChangeSet=c,t.isTuple=function(t){return!(!t||!o(t))},t.rederive=h,t.replace=function(t,n){return a(n,o(t))},t.stableCompare=function(t,n){return t?n?(e,r)=>t(e,r)||o(n(e))-o(n(r)):(n,e)=>t(n,e)||o(n)-o(e):null},t.transform=K,t.transforms=J,t.tupleid=o,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 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.pulse=n||t);var n};var k=0;function F(t,n,e){this.id=++k,this.value=null,e&&(this.receive=e),t&&(this._filter=t),n&&(this._apply=n)}function A(t,n,e){return new F(t,n,e)}var D=F.prototype;D._filter=n.truthy,D._apply=n.identity,D.targets=function(){return this._targets||(this._targets=r(n.id))},D.consume=function(t){return arguments.length?(this._consume=!!t,this):!!this._consume},D.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())}},D.filter=function(t){var n=A(t);return this.targets().add(n),n},D.apply=function(t){var n=A(null,t);return this.targets().add(n),n},D.merge=function(){var t=A();this.targets().add(t);for(var n=0,e=arguments.length;n<e;++n)arguments[n].targets().add(t);return t},D.throttle=function(t){var n=-1;return this.filter((function(){var e=Date.now();return e-n>t?(n=e,1):0}))},D.debounce=function(t){var e=A();return this.targets().add(A(null,null,n.debounce(t,(function(t){var n=t.dataflow;e.receive(t),n&&n.run&&n.run()})))),e},D.between=function(t,n){var e=!1;return t.targets().add(A(null,null,(function(){e=!0}))),n.targets().add(A(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=n=>t.touch(r(n)):n.isFunction(i)?(o=new _(null,i,s,!1),a=n=>{o.evaluate(n);const e=r(n),i=o.value;c(i)?t.pulse(e,i,u):t.update(e,i,l)}):a=n=>t.update(r(n),i,l),e.apply(a)}function b(t,e,r,i,s,u){if(void 0===i)e.targets().add(r);else{const a=u||{},o=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);o.modified(a.force),o.rank=e.rank,e.targets().add(o),r&&(o.skip(!0),o.value=r.value,o.targets().add(r),t.connect(r,[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 C(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=this.fields||(this.fields={});return n.isArray(t)?t.forEach(t=>e[t]=!0):e[t]=!0,this},S.modified=function(t,e){var r=this.fields;return!(!e&&!this.mod.length||!r)&&(arguments.length?n.isArray(t)?t.some((function(t){return r[t]})):r[t]:!!r)},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 T=n.inherits(C,M);function z(t){return t.error("Dataflow already running. Use runAsync() to chain invocations."),t}T.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},T.changed=function(t){return this.changes&t},T.modified=function(t){var e=this,r=e.fields;return r&&e.changes&e.MOD?n.isArray(t)?t.some((function(t){return r[t]})):r[t]:0},T.filter=function(){n.error("MultiPulse does not support filtering.")},T.materialize=function(){n.error("MultiPulse does not support materialization.")},T.visit=function(t,n){var e=this,r=e.pulses,i=r.length,s=0;if(t&e.SOURCE)for(;s<i;++s)r[s].visit(t,n);else for(;s<i;++s)r[s].stamp===e.stamp&&r[s].visit(t,n);return e};var I={skip:!1,force:!1};function U(t){var n=[];return{clear:()=>n=[],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._input={},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._input[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=A(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(),o=[];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 l,h,c,f,d=++u._clock,p=0;u._pulse=new M(u,d,t),a>=n.Info&&(c=Date.now(),u.debug("-- START PROPAGATION ("+d+") -----")),u._touched.forEach(t=>u._enqueue(t,!0)),u._touched=r(n.id);try{for(;u._heap.size()>0;)l=u._heap.pop(),l.rank===l.qrank?(h=l.run(u._getPulse(l,t)),h.then?h=await h:h.async&&(o.push(h.async),h=q),a>=n.Debug&&u.debug(l.id,h===q?"STOP":h,l),h!==q&&l._targets&&l._targets.forEach(t=>u._enqueue(t)),++p):u._enqueue(l,!0)}catch(t){u._heap.clear(),f=t}if(u._input={},u._pulse=null,a>=n.Info&&(c=Date.now()-c,u.info("> Pulse "+d+": "+p+" operators; "+c+"ms")),f&&(u._postrun=[],u.error(f)),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),o.length&&Promise.all(o).then(t=>u.runAsync(null,()=>{t.forEach(t=>{try{t(u)}catch(t){u.error(t)}})})),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=t.stamp<this._clock;e&&(t.stamp=this._clock),(e||n)&&(t.qrank=t.rank,this._heap.push(t))},G._getPulse=function(t,e){var r=t.source,i=this._clock;return r&&n.isArray(r)?new C(this,i,r.map(t=>t.pulse),e):this._input[t.id]||function(t,n){if(n&&n.stamp===t.stamp)return n;t=t.fork(),n&&n!==q&&(t.source=n.source);return t}(this._pulse,r&&r.pulse)},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).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(),n.hasOwnProperty(J,t)?J[t]:null}t.Dataflow=N,t.EventStream=F,t.MultiPulse=C,t.Operator=_,t.Parameters=p,t.Pulse=M,t.Transform=B,t.UniqueList=r,t.asyncCallback=i,t.changeset=f,t.definition=function(t){var n=K(t);return n&&n.Definition||null},t.derive=function(t){return h(t,l({}))},t.ingest=l,t.isChangeSet=c,t.isTuple=function(t){return!(!t||!a(t))},t.rederive=h,t.replace=function(t,n){return o(n,a(t))},t.stableCompare=function(t,n){return t?n?(e,r)=>t(e,r)||a(n(e))-a(n(r)):(n,e)=>t(n,e)||a(n)-a(e):null},t.transform=K,t.transforms=J,t.tupleid=a,Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "vega-dataflow",
"version": "5.4.1",
"version": "5.5.0",
"description": "Reactive dataflow processing.",

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

},
"gitHead": "e9ce2c4394348a304ac8c00c1c36efdf66abbb46"
"gitHead": "b690910bacfcb2580511e262400e496d9b14b04f"
}

@@ -30,3 +30,4 @@ /* eslint-disable require-atomic-updates */

const df = this,
level = df.logLevel();
level = df.logLevel(),
async = [];

@@ -77,5 +78,9 @@ // if the pulse value is set, this is a re-entrant call

// await if operator returned a promise
if (next.then) {
// await if operator returns a promise directly
next = await next;
} else if (next.async) {
// queue parallel asynchronous execution
async.push(next.async);
next = StopPropagation;
}

@@ -126,2 +131,9 @@

// handle non-blocking asynchronous callbacks
if (async.length) {
Promise.all(async).then(cb => df.runAsync(null, () => {
cb.forEach(f => { try { f(df); } catch (err) { df.error(err); } });
}));
}
return df;

@@ -128,0 +140,0 @@ }

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