Return an partial of `.exec`, with `node` set to :obj:`.node`, and `js` set to current javascripts in queue: (setup + run + post). :param expr: Optional. If given, the expression will be added to :obj:`.run`.
(self, expr: Optional[JsExpr] = None)
| 142 | return removesuffix(stdout.decode()) |
| 143 | |
| 144 | def bind(self, expr: Optional[JsExpr] = None): |
| 145 | """Return an partial of `.exec`, with `node` set to :obj:`.node`, |
| 146 | and `js` set to current javascripts in queue: (setup + run + post). |
| 147 | |
| 148 | :param expr: Optional. If given, the expression will be added to :obj:`.run`. |
| 149 | """ |
| 150 | js = "" |
| 151 | if expr is None: |
| 152 | pass |
| 153 | elif isinstance(expr, Partial): |
| 154 | self.add_run("console.log", expr) |
| 155 | else: |
| 156 | self.run.append(f"console.log({expr})") |
| 157 | for expr in chain(self.setup, self.run, self.post): |
| 158 | js += str(expr) |
| 159 | js += ";" |
| 160 | return partial(self.exec, node=self.node, js=js) |
| 161 | |
| 162 | async def __call__(self, expr: Optional[JsExpr]): |
| 163 | """Run current javascripts. :obj:`.run` will be cleared. |