Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function* sequence(): Sequence {
//bare generator function is ok
let value: number = yield function*() { return 5; }
// you can always yield undefined;
yield;
// other Operation also ok.
yield sequence
// can yield to forks
yield fork(function*() { yield });
}
function* asynchronous(): Sequence {
fork(sequence);
fork(sequence());
}
import { Execution, Sequence, fork } from 'effection';
function* operation(): Sequence {}
let execution: Execution;
execution = fork(operation);
execution = fork(operation());
execution = fork(Promise.resolve("hello world"));
execution = fork(function*() {});
execution = fork(undefined);
execution = fork((execution: Execution) => {
execution.id;
execution.resume(10);
execution.halt("optional reason");
execution.halt();
execution.throw(new Error('boom!'));
});
import { Execution, Sequence, fork } from 'effection';
function* operation(): Sequence {}
let execution: Execution;
execution = fork(operation);
execution = fork(operation());
execution = fork(Promise.resolve("hello world"));
execution = fork(function*() {});
execution = fork(undefined);
execution = fork((execution: Execution) => {
execution.id;
execution.resume(10);
execution.halt("optional reason");
execution.halt();
execution.throw(new Error('boom!'));
});
function* asynchronous(): Sequence {
fork(sequence);
fork(sequence());
}
async function someAsyncFunction() {
await fork(function*() {
yield
});
await Promise.all([
fork(function*() { yield }),
fork(function*() { yield }),
]);
let someFork = fork(function*() {
yield
return 123;
});
someFork.then((value: number) => {}, (error) => {});
someFork.catch((error: Error) => "string").then((some: string) => {});
someFork.finally(() => "string").then((some: number) => {});
}
import { Execution, Sequence, fork } from 'effection';
function* operation(): Sequence {}
let execution: Execution;
execution = fork(operation);
execution = fork(operation());
execution = fork(Promise.resolve("hello world"));
execution = fork(function*() {});
execution = fork(undefined);
execution = fork((execution: Execution) => {
execution.id;
execution.resume(10);
execution.halt("optional reason");
execution.halt();
execution.throw(new Error('boom!'));
});
import { fork } from 'effection';
fork(5);
function* operation(): Sequence {}
let execution: Execution;
execution = fork(operation);
execution = fork(operation());
execution = fork(Promise.resolve("hello world"));
execution = fork(function*() {});
execution = fork(undefined);
execution = fork((execution: Execution) => {
execution.id;
execution.resume(10);
execution.halt("optional reason");
execution.halt();
execution.throw(new Error('boom!'));
});
import { Execution, Sequence, fork } from 'effection';
function* operation(): Sequence {}
let execution: Execution;
execution = fork(operation);
execution = fork(operation());
execution = fork(Promise.resolve("hello world"));
execution = fork(function*() {});
execution = fork(undefined);
execution = fork((execution: Execution) => {
execution.id;
execution.resume(10);
execution.halt("optional reason");
execution.halt();
execution.throw(new Error('boom!'));
});