MCPcopy Index your code
hub / github.com/MALSync/MALSync / ifNotReturn

Function ifNotReturn

src/chibiScript/functions/controlFlowFunctions.ts:73–85  ·  view source on GitHub ↗

* If the input is falsy stop further execution and return the result of returnAction * @input condition - Boolean condition to evaluate * @param returnAction - Action to execute if input is falsy * @example * $c.querySelector('a').ifNotReturn($c.number(0).run()).text().trim().run(); *

(
    ctx: ChibiCtx,
    input: Input,
    returnAction?: ChibiJson<any>,
  )

Source from the content-addressed store, hash-verified

71 * $c.querySelector('a').ifNotReturn().text().trim().run();
72 */
73 ifNotReturn<Input>(
74 ctx: ChibiCtx,
75 input: Input,
76 returnAction?: ChibiJson<any>,
77 ): Exclude<Input, false | 0 | '' | null | undefined> {
78 if (input) {
79 return input as any;
80 }
81 if (ctx.isAsync()) {
82 return ctx.return(returnAction ? ctx.runAsync(returnAction) : null) as any;
83 }
84 return ctx.return(returnAction ? ctx.run(returnAction) : null) as any;
85 },
86};

Callers

nothing calls this directly

Calls 4

isAsyncMethod · 0.80
returnMethod · 0.80
runAsyncMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected