Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function assertSourcesSinks(sources, sinks, main, done, timeOpts = {}) {
const Time = mockTimeSource(timeOpts);
const _sources = Object.keys(sources).reduce((_sources, sourceKey) => {
const sourceObj = sources[sourceKey];
const diagram = Object.keys(sourceObj)[0];
const sourceOpts = sourceObj[diagram];
let obj = {};
let firstKey = Object.keys(sourceOpts)[0];
if (typeof sourceOpts[firstKey] === 'function') {
obj = {
[sourceKey]: {
// pass category to select
[firstKey]: (...args) =>
Time.diagram(diagram, sourceOpts[firstKey](...args)),
},
};
} else {
export function assertSourcesSinks(sources, sinks, main, done, timeOpts = {}) {
const Time = mockTimeSource(timeOpts);
const _sources = Object.keys(sources).reduce((_sources, sourceKey) => {
const sourceObj = sources[sourceKey];
const diagram = Object.keys(sourceObj)[0];
const sourceOpts = sourceObj[diagram];
let obj = {};
let firstKey = Object.keys(sourceOpts)[0];
if (typeof sourceOpts[firstKey] === 'function') {
obj = {
[sourceKey]: {
// pass category to select
[firstKey]: (...args) =>
Time.diagram(diagram, sourceOpts[firstKey](...args)),
},
};
} else if (firstKey === 'local') {
function run (app, makeDrivers) {
const Time = timeDriver(null, null);
const newMakeDrivers = () => {
const drivers = makeDrivers();
drivers.Time = () => Time;
return drivers;
}
const rerun = rerunner(originalRun, newMakeDrivers);
const stuff = rerun(app);
const awesomeStreams = streamGraph(stuff.sinks);
function InnerApp (sources) {
function restart (setup, main, drivers, cb, {sources, sinks, dispose}, isolate = {}, timeToTravelTo = null) {
dispose();
if (typeof isolate === 'function' && 'reset' in isolate) {
isolate.reset();
}
const realTime = timeDriver();
realTime._pause();
drivers.Time = () => realTime;
for (let driverName in drivers) {
const driver = drivers[driverName];
const newDriver = (sink$) => driver(sink$, realTime);
newDriver.replayLog = driver.replayLog;
newDriver.onPostReplay = driver.onPostReplay;
newDriver.log$ = driver.log$;
drivers[driverName] = newDriver;
if (driver.onPreReplay) {
return function(main, cb = noop, timeToTravelTo = null) {
if (first) {
drivers = driversFn();
let realTime = timeDriver();
drivers.Time = () => realTime;
for (let driverName in drivers) {
const driver = drivers[driverName];
const newDriver = (sink$) => driver(sink$, realTime);
drivers[driverName] = newDriver;
}
const {sources, sinks, run} = Cycle(main, drivers);
realTime = sources.Time;
const dispose = run();
export function mockTimeSource(args?: Object): MockTimeSource {
return mockTimeSourceUntyped(args);
}
export function timeDriver(sink: any): TimeSource {
return timeDriverUntyped(sink);
}