* 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>,
)
| 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 | }; |