-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
abort() - Abort Signal aka break (#66)
* Abort() BotAction - interface, helper functions, and BotAction to return a signal for aborting - House Cleaning / Helper Test * ChainRunner updated with abort line signal support * chain()() enhanced with AbortLineSignal support * pipeRunner()() enhanced to support AbortLineSignal * Default BotAction returns void or AbortLineSignal * pipe()() supports AbortLineSignal * Upgraded Utilities with AbortLineSignal support * doWhile supports AbortLineSignal * forAsLong supports AbortLineSignal * pipeActionOrActions() supports AbortLineSignal * assemblyLine supports AbortLineSignal + tweaks * chainRunner will return AbortLineSignal.pipeValue when it's the last aborted BotAction line * assemblyLine running a chain will return AbortLineSignal.pipeValue when it's the last aborted Botaction line * chain will not return AbortLineSignal.pipeValue when it's the last aborted botaction in line * this creates a series of steps to shift in functional complexity from chain -> assemblyLine (as chain) -> assembyLine(true) (as pipe) -> pipe * forAsLong standardized & processAbortLineSignal * processAbortLineSignal() helper unit-tested * Utilities & Assembly Lines using processAbortLineSignal() * tests are passing, coverage is passing * Errors updated to support AbortLineSignal * theory unit tests for chain/pipe on deep aborting * additional assertion theory test
- Loading branch information
Showing
19 changed files
with
1,709 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { BotAction } from "../interfaces" | ||
import { AbortLineSignal } from '../types' | ||
import { PipeValue } from "../types/pipe-value" | ||
import { createAbortLineSignal } from "../helpers/abort" | ||
|
||
/** | ||
* BotAction to return an AbortLineSignal to be processed by an assembler for an effect of aborting assembled lines (including parent(s) if specified a number greater than 1 or 0 for all) | ||
* @param assembledLines number of lines (from current to parent, to grandparent, to grandgrandparent, ...) to break from continuing further | ||
* 0 means all, a way to kill a bot | ||
* @param pipeValue works only in a Pipe assembler, optional, but if a Pipe assembler is aborted, it can return the pipeValue provided in the AbortLineSignal | ||
or pass it along to the next assembler if the assembledLines is greater than 1 as the pipeValue is returned by the final aborted assembler | ||
*/ | ||
export const abort = (assembledLines = 1, pipeValue?: PipeValue): BotAction<AbortLineSignal> => | ||
async() => createAbortLineSignal(assembledLines, pipeValue) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import { BotAction } from "../interfaces" | ||
import { PipeValue } from "../types/pipe-value" | ||
import { assemblyLine } from "./assembly-lines" | ||
import { AbortLineSignal } from "../types/abort-signal" | ||
|
||
/** | ||
* @description Higher-order to set the first few injects for wrapped BotAction's | ||
* @note If you need the injects to run as a pipe, wrap injects in pipe()() otherwise assemblyLine()() will run it as a chain | ||
*/ | ||
export const inject = | ||
(...newInjects: any[]) => | ||
(...actions: BotAction<PipeValue|void>[]): BotAction<any> => | ||
(...actions: BotAction<PipeValue|void|AbortLineSignal>[]): BotAction<any> => | ||
async(page, ...injects) => | ||
await assemblyLine()(...actions)(page, ...newInjects, ...injects) |
Oops, something went wrong.