- Google ZX v1.x for Nim.
Example: cmd: -b:js -r:off -d:danger -d:nimExperimentalJsfetch
import src/nodejs/jszx import std/[jsffi, asyncjs, jsfetch] proc main() {.async.} = echo zxprefix, zxshell doAssert zxverbose sleep 9 discard(await question"Whats up?") discard(await $$"pwd") discard(await nothrow($$"NONEXISTENT")) echo toCstring(await $$"pwd") let resp = await fetch"http://wttr.in" if resp.ok: echo(await resp.text()) cd"/tmp" discard main()
Types
ProcessOutput = ref object of JsRoot stdout*, stderr*: cstring exitCode*: int
Procs
func `$$`(commands: cstring): Future[ProcessOutput] {.importjs: "$$`#`", discardable, ...raises: [], tags: [].}
func cd(path: cstring) {.importjs: "$1(#)", ...raises: [], tags: [].}
func fetch(url: cstring): Future[Response] {.importjs: "$1(#)", ...raises: [], tags: [].}
func fetch(url: cstring; options: FetchOptions): Future[Response] {. importjs: "$1(#)", ...raises: [], tags: [].}
func nothrow[T](promise: T): T {.importjs: "$1(#)", discardable, ...raises: [], tags: [].}
func question(query: cstring): Future[cstring] {.importjs: "$1(#)", discardable, ...raises: [], tags: [].}
func sleep(time: SomeInteger) {.importjs: "$1(#)", ...raises: [], tags: [].}
func toCstring(self: ProcessOutput): cstring {.importjs: "#.toString()", ...raises: [], tags: [].}