A QuickJS wrapper for Nim 👑
Burrito is a comprehensive wrapper around the QuickJS JavaScript engine for Nim. It lets you embed JavaScript execution directly into your Nim applications with minimal overhead.
Drop a complete JavaScript REPL with syntax highlighting, command history, and custom Nim function exposure into your application with just a few lines of code!
cat > burrito_repl.nim <<EOF import burrito # Create QuickJS with full standard library support var js = newQuickJS(configWithBothLibs()) # Expose custom Nim function to the REPL proc greet(ctx: ptr JSContext, name: JSValue): JSValue = let nameStr = toNimString(ctx, name) result = nimStringToJS(ctx, "Hello from Nim, " & nameStr & "!") js.registerFunction("greet", greet) # Start the embedded REPL let replCode = readFile("quickjs/repl.js") discard js.evalModule(replCode, "<repl>") js.runPendingJobs() js.processStdLoop() # Interactive REPL runs here! js.close() EOF nim r burrito_repl.nim
cat > burrito_example.nim <<EOF import burrito var js = newQuickJS() echo js.eval("3 + 4") echo js.eval("'Hello ' + 'World!'") proc greet(ctx: ptr JSContext, name: JSValue): JSValue = let nameStr = toNimString(ctx, name) result = nimStringToJS(ctx, "Hello from Nim, " & nameStr & "!") js.registerFunction("greet", greet) echo js.eval("greet('Burrito')") js.close() EOF nim r burrito_example.nim
# Clone and setup Burrito git clone https://github.com/tapsterbot/burrito.git cd burrito # Download and build QuickJS nimble get_quickjs nimble build_quickjs # Now you can use Burrito! nimble example
scripting Nim applications, configuration with JavaScript, plugin systems, dynamic code execution, user-defined functions, testing and mocking, template engines, automation workflows, live code editing, interactive debugging, game scripting, bot programming, creative coding, procrastination tools, ordering lunch, making coffee, finding socks, training cats, flying drones, driving cars, talking to robots, and prototyping and experimentation.
Full-featured JavaScript REPL with syntax highlighting and command history
Seamlessly call Nim from JavaScript and JavaScript from Nim
Zero-overhead C function bridging for maximum speed
Automatic type marshaling between Nim and JavaScript
Simple API that gets you up and running in minutes
Access to std and os modules for complete functionality