MCPcopy Create free account
hub / github.com/Snowflyt/tinyeffect / terminate

Method terminate

src/effected.ts:844–858  ·  view source on GitHub ↗
(effect: any, handler: (...payloads: unknown[]) => unknown)

Source from the content-addressed store, hash-verified

842 : never,
843 ): Effected<ExcludeEffect<E, Effect<Name>>, R | T>;
844 terminate(effect: any, handler: (...payloads: unknown[]) => unknown) {
845 return this.handle(effect, (({ terminate }: any, ...payloads: unknown[]) => {
846 const it = handler(...payloads);
847 if (!(it instanceof Effected) && !isGenerator(it)) return terminate(it);
848 const iterator = it[Symbol.iterator]();
849 return {
850 _effectedIterator: true,
851 next: (...args: [] | [unknown]) => {
852 const result = iterator.next(...args);
853 if (result.done) return { done: true, value: terminate(result.value) };
854 return result;
855 },
856 };
857 }) as never);
858 }
859
860 /**
861 * Overwrite the return value of the effected program with a new value.

Callers 1

catchMethod · 0.95

Calls 3

handleMethod · 0.95
isGeneratorFunction · 0.85
terminateFunction · 0.85

Tested by

no test coverage detected