🌯 Burrito

A QuickJS wrapper for Nim 👑

What is Burrito?

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.

🎯

The Killer Feature

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!

Embedded REPL Example

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

Basic Usage

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

Installation

# 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

Perfect for:

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.

Key Features

🎨

Embeddable REPL

Full-featured JavaScript REPL with syntax highlighting and command history

🔗

Two-way Binding

Seamlessly call Nim from JavaScript and JavaScript from Nim

🚀

Native Performance

Zero-overhead C function bridging for maximum speed

🧠

Smart Types

Automatic type marshaling between Nim and JavaScript

📦

Easy Integration

Simple API that gets you up and running in minutes

📚

Full QuickJS Support

Access to std and os modules for complete functionality