@cycle/run
Advanced tools
Comparing version 4.0.0-rc.1 to 4.0.0-rc.2
@@ -0,1 +1,6 @@ | ||
<a name="3.2.0"></a> | ||
# 3.2.0 (2017-08-12) | ||
<a name="3.1.0"></a> | ||
@@ -2,0 +7,0 @@ # 3.1.0 (2017-03-24) |
@@ -33,3 +33,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Cycle = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
if (drivers.hasOwnProperty(name_1)) { | ||
sinkProxies[name_1] = xstream_1.default.create(); | ||
sinkProxies[name_1] = xstream_1.default.createWithMemory(); | ||
} | ||
@@ -36,0 +36,0 @@ } |
(function(n){"object"===typeof exports&&"undefined"!==typeof module?module.exports=n():"function"===typeof define&&define.amd?define([],n):("undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:this).Cycle=n()})(function(){return function l(h,a,g){function p(f,d){if(!a[f]){if(!h[f]){var k="function"==typeof require&&require;if(!d&&k)return k(f,!0);if(m)return m(f,!0);d=Error("Cannot find module '"+f+"'");throw d.code="MODULE_NOT_FOUND",d;}d=a[f]={exports:{}}; | ||
h[f][0].call(d.exports,function(a){var d=h[f][1][a];return p(d?d:a)},d,d.exports,l,h,a,g)}return a[f].exports}for(var m="function"==typeof require&&require,k=0;k<g.length;k++)p(g[k]);return p}({1:[function(l,h,a){Object.defineProperty(a,"__esModule",{value:!0});var g=function(a){return a};a.setAdapt=function(a){g=a};a.adapt=function(a){return g(a)}},{}],2:[function(l,h,a){(function(g){function h(e){var b={},a;for(a in e)e.hasOwnProperty(a)&&(b[a]=r.default.create());return b}function m(a,b){var e= | ||
{},c;for(c in a)a.hasOwnProperty(c)&&(e[c]=a[c](b[c],c),e[c]&&"object"===typeof e[c]&&(e[c]._isCycleSource=c));return e}function k(a){for(var b in a)a.hasOwnProperty(b)&&a[b]&&"function"===typeof a[b].shamefullySendNext&&(a[b]=t.adapt(a[b]));return a}function f(a,b){var e=Object.keys(a).filter(function(a){return!!b[a]}),c={},d={};e.forEach(function(a){c[a]={_n:[],_e:[]};d[a]={next:function(b){return c[a]._n.push(b)},error:function(b){return c[a]._e.push(b)},complete:function(){}}});var f=e.map(function(b){return r.default.fromObservable(a[b]).subscribe(d[b])}); | ||
e.forEach(function(a){var e=b[a],f=function(a){e._n(a)},g=function(a){var b=a.stack||a;console&&console.error?console.error(b):console&&console.log&&console.log(b);e._e(a)};c[a]._n.forEach(f);c[a]._e.forEach(g);d[a].next=f;d[a].error=g;d[a]._n=f;d[a]._e=g});c=null;return function(){f.forEach(function(a){return a.unsubscribe()});e.forEach(function(a){return b[a]._c()})}}function d(a,b){if("function"!==typeof a)throw Error("First argument given to Cycle must be the 'main' function.");if("object"!== | ||
typeof b||null===b)throw Error("Second argument given to Cycle must be an object with driver functions as properties.");if(0===Object.keys(b).length)throw Error("Second argument given to Cycle must be an object with at least one driver function declared as a property.");var d=h(b),c=m(b,d);b=k(c);var e=a(b);"undefined"!==typeof window&&(window.Cyclejs=window.Cyclejs||{},window.Cyclejs.sinks=e);return{sinks:e,sources:c,run:function(){var a=f(e,d);return function(){for(var b in c)c.hasOwnProperty(b)&& | ||
h[f][0].call(d.exports,function(a){var d=h[f][1][a];return p(d?d:a)},d,d.exports,l,h,a,g)}return a[f].exports}for(var m="function"==typeof require&&require,k=0;k<g.length;k++)p(g[k]);return p}({1:[function(l,h,a){Object.defineProperty(a,"__esModule",{value:!0});var g=function(a){return a};a.setAdapt=function(a){g=a};a.adapt=function(a){return g(a)}},{}],2:[function(l,h,a){(function(g){function h(e){var b={},a;for(a in e)e.hasOwnProperty(a)&&(b[a]=r.default.createWithMemory());return b}function m(a, | ||
b){var e={},c;for(c in a)a.hasOwnProperty(c)&&(e[c]=a[c](b[c],c),e[c]&&"object"===typeof e[c]&&(e[c]._isCycleSource=c));return e}function k(a){for(var b in a)a.hasOwnProperty(b)&&a[b]&&"function"===typeof a[b].shamefullySendNext&&(a[b]=t.adapt(a[b]));return a}function f(a,b){var e=Object.keys(a).filter(function(a){return!!b[a]}),c={},d={};e.forEach(function(a){c[a]={_n:[],_e:[]};d[a]={next:function(b){return c[a]._n.push(b)},error:function(b){return c[a]._e.push(b)},complete:function(){}}});var f= | ||
e.map(function(b){return r.default.fromObservable(a[b]).subscribe(d[b])});e.forEach(function(a){var e=b[a],f=function(a){e._n(a)},g=function(a){var b=a.stack||a;console&&console.error?console.error(b):console&&console.log&&console.log(b);e._e(a)};c[a]._n.forEach(f);c[a]._e.forEach(g);d[a].next=f;d[a].error=g;d[a]._n=f;d[a]._e=g});c=null;return function(){f.forEach(function(a){return a.unsubscribe()});e.forEach(function(a){return b[a]._c()})}}function d(a,b){if("function"!==typeof a)throw Error("First argument given to Cycle must be the 'main' function."); | ||
if("object"!==typeof b||null===b)throw Error("Second argument given to Cycle must be an object with driver functions as properties.");if(0===Object.keys(b).length)throw Error("Second argument given to Cycle must be an object with at least one driver function declared as a property.");var d=h(b),c=m(b,d);b=k(c);var e=a(b);"undefined"!==typeof window&&(window.Cyclejs=window.Cyclejs||{},window.Cyclejs.sinks=e);return{sinks:e,sources:c,run:function(){var a=f(e,d);return function(){for(var b in c)c.hasOwnProperty(b)&& | ||
c[b]&&c[b].dispose&&c[b].dispose();a()}}}}function q(a,b){a=d(a,b);"undefined"!==typeof window&&window.CyclejsDevTool_startGraphSerializer&&window.CyclejsDevTool_startGraphSerializer(a.sinks);return a.run()}Object.defineProperty(a,"__esModule",{value:!0});var r="undefined"!==typeof window?window.xstream:"undefined"!==typeof g?g.xstream:null,t=l("./adapt");a.setup=d;a.run=q;a.default=q}).call(this,"undefined"!==typeof global?global:"undefined"!==typeof self?self:"undefined"!==typeof window?window: | ||
{})},{"./adapt":1}]},{},[2])(2)}); |
@@ -85,2 +85,11 @@ "use strict"; | ||
} | ||
function clearBuffers(sources) { | ||
for (var k in sources) { | ||
if (sources.hasOwnProperty(k) && | ||
sources[k] && | ||
sources[k].clearBuffer) { | ||
sources[k].clearBuffer(); | ||
} | ||
} | ||
} | ||
function disposeSources(sources) { | ||
@@ -148,2 +157,3 @@ for (var k in sources) { | ||
var disposeReplication = replicateMany(sinks, sinkProxies); | ||
clearBuffers(sources); | ||
return function dispose() { | ||
@@ -150,0 +160,0 @@ disposeSources(sources); |
{ | ||
"name": "@cycle/run", | ||
"version": "4.0.0-rc.1", | ||
"version": "4.0.0-rc.2", | ||
"description": "The Cycle.js run() function to use with xstream", | ||
@@ -29,2 +29,3 @@ "license": "MIT", | ||
"main": "lib/index.js", | ||
"module": "lib/es6/index.js", | ||
"typings": "lib/index.d.ts", | ||
@@ -31,0 +32,0 @@ "types": "lib/index.d.ts", |
@@ -152,2 +152,14 @@ import xs, {Stream} from 'xstream'; | ||
function clearBuffers<So extends Sources>(sources: So) { | ||
for (const k in sources) { | ||
if ( | ||
sources.hasOwnProperty(k) && | ||
sources[k] && | ||
(sources[k] as any).clearBuffer | ||
) { | ||
(sources[k] as any).clearBuffer(); | ||
} | ||
} | ||
} | ||
function disposeSources<So extends Sources>(sources: So) { | ||
@@ -229,2 +241,3 @@ for (const k in sources) { | ||
const disposeReplication = replicateMany(sinks, sinkProxies); | ||
clearBuffers(sources); | ||
return function dispose() { | ||
@@ -231,0 +244,0 @@ disposeSources(sources); |
@@ -598,2 +598,81 @@ import 'mocha'; | ||
}); | ||
it('should clear too-early buffers in drivers', function(done) { | ||
function main(sources: any) { | ||
const test$ = xs | ||
.of(null) | ||
.compose(delay(1000)) | ||
.map(() => | ||
sources.HTTP | ||
.select('cat') // .flatten() | ||
.map((res: any) => 'I should not show this, ' + res.text), | ||
) | ||
.flatten(); | ||
const request$ = xs.of({ | ||
category: 'cat', | ||
url: 'http://jsonplaceholder.typicode.com/users/1', | ||
}); | ||
return { | ||
HTTP: request$, | ||
Test: test$, | ||
}; | ||
} | ||
function testDriver(sink: any) { | ||
sink.addListener({ | ||
next: (s: string) => { | ||
console.log(s); | ||
done('No data should come through the Test sink'); | ||
}, | ||
error: (err: any) => { | ||
done(err); | ||
}, | ||
}); | ||
} | ||
function httpDriver(sink: Stream<any>) { | ||
let isBufferOpen = true; | ||
const buffer: Array<any> = []; | ||
const earlySource = xs.create({ | ||
start(listener: any) { | ||
while (buffer.length > 0) { | ||
listener.next(buffer.shift()); | ||
} | ||
isBufferOpen = false; | ||
}, | ||
stop() {}, | ||
}); | ||
const source = sink.map(req => ({body: {name: 'Louis'}})); | ||
source.addListener({ | ||
next: x => { | ||
if (isBufferOpen) { | ||
buffer.push(x); | ||
} | ||
}, | ||
error: (err: any) => {}, | ||
}); | ||
return { | ||
select: function() { | ||
return xs.merge(earlySource, source); | ||
}, | ||
clearBuffer: function() { | ||
while (buffer.length > 0) { | ||
buffer.shift(); | ||
} | ||
}, | ||
}; | ||
} | ||
const dispose = run(main, { | ||
HTTP: httpDriver, | ||
Test: testDriver, | ||
}); | ||
setTimeout(() => { | ||
dispose(); | ||
done(); | ||
}, 1800); | ||
}); | ||
}); |
{ | ||
"extends": "../tsconfig.common.json", | ||
"compilerOptions": { | ||
"outDir": "lib/" | ||
}, | ||
@@ -6,0 +5,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
79653
30
1765
0