Node.js bindings to Lua

Overview

@cbrewster/luna

Node.js bindings to Lua.

{ console.log(`key: ${key} val: ${val}`); }); } const selfReference = await lua.doString("x = {} \n x.self = x \n return x"); if (selfReference instanceof LuaTable) { selfReference.forEach((key, val) => { console.log(`key: ${key} val: ${val}`); if (val?.toString() === selfReference.toString()) { console.log("we have a cycle!"); console.log("Table: ", selfReference.toString()); } }); } lua.close(); })()">
import { Lua, LuaTable } from '@cbrewster/luna';

(async () => {
  const lua = new Lua();

  console.log(await lua.doString("x = 1")); // null
  console.log(await lua.doString("return x")); // 1

  try {
    await lua.doString("this is a syntax error"); // Error!
  } catch (e) {
    console.log(e); 
  }
  
  console.log(await lua.doString("return 1 + 2")); // 3
  console.log(await lua.doString(`return "abc"`)); // "abc"

  const table = await lua.doString(`return {key = "value", foo = "bar"}`);
  if (table instanceof LuaTable) {
    table.forEach((key, val) => {
      console.log(`key: ${key} val: ${val}`);
    });
  }
  
  const selfReference = await lua.doString("x = {} \n x.self = x \n return x");
  if (selfReference instanceof LuaTable) {
    selfReference.forEach((key, val) => {
      console.log(`key: ${key} val: ${val}`);
      if (val?.toString() === selfReference.toString()) {
        console.log("we have a cycle!");
        console.log("Table: ", selfReference.toString());
      }
    });
  }

  lua.close();
})()
You might also like...
📦 Pack hundreds of Garry's Mod Lua files into just a handful
📦 Pack hundreds of Garry's Mod Lua files into just a handful

📦 gluapack gluapack is a program that can pack hundreds of Garry's Mod Lua files into just a handful. Features Quick, easy and portable - perfect for

A memory safe Lua interpreter

Hematita Da Lua Hematita Da Lua is an interpreter for the scripting language Lua, written entirely in 100% safe Rust. Hematita is the portugese word f

A script language like Python or Lua written in Rust, with exactly the same syntax as Go's.

A script language like Python or Lua written in Rust, with exactly the same syntax as Go's.

A super-lightweight Lua microservice (toy) framework.

Hive A super-lightweight microservice (toy) framework written in Rust. It uses Lua as interface to provide simple, fun developing experience and fast

🐱‍👤 Cross-language static library for accessing the Lua state in Garry's Mod server plugins

gmserverplugin This is a utility library for making Server Plugins that access the Lua state in Garry's Mod. Currently, accessing the Lua state from a

A parser, compiler, and virtual machine evaluator for a minimal subset of Lua; written from scratch in Rust.

lust: Lua in Rust This project implements a parser, compiler, and virtual machine evaluator for a minimal subset of Lua. It is written from scratch in

Rust scaffold system with Lua embedded applets.
Rust scaffold system with Lua embedded applets.

brickpack-2022 Demo Powered by Github Actions CI/CD (Heroku) https://demo-1642622230.herokuapp.com/#/users Frontent Runner Rendered sample code (Lua 5

This tool converts Lua code to TS automatically, including the conversion of common standards to their TS equivalents.

lua-to-ts This tool converts Lua code to TS automatically, including the conversion of common standards to their TS equivalents. Code that fails to be

Another cursed Garry's Mod module. This time, it adds the C preprocessor to Lua scripts

gm_cpreprocessor Another cursed Garry's Mod module. This time, it adds the C preprocessor to Lua scripts. It works by detouring RunStringEx and overri

Releases(0.0.10)
Owner
Connor Brewster
Software Engineer @ Replit.com, Rust Enthusiast
Connor Brewster
Lua 5.3 bindings for Rust

rust-lua53 Aims to be complete Rust bindings for Lua 5.3 and beyond. Currently, master is tracking Lua 5.3.3. Requires a Unix-like environment. On Win

J.C. Moyer 150 Dec 14, 2022
Safe Rust bindings to Lua 5.1

rust-lua Copyright 2014 Lily Ballard Description This is a set of Rust bindings to Lua 5.1. The goal is to provide a (relatively) safe interface to Lu

Lily Ballard 124 Jan 5, 2023
A minimal library for building compiled Node.js add-ons in Rust via Node-API

A minimal library for building compiled Node.js add-ons in Rust via Node-API

Node-API (N-API) for Rust 3.1k Dec 29, 2022
Rust bindings for writing safe and fast native Node.js modules.

Rust bindings for writing safe and fast native Node.js modules. Getting started Once you have the platform dependencies installed, getting started is

The Neon Project 7k Jan 4, 2023
Native webview bindings for Node.js

webview-native Native webview bindings for Node.js Installing webview-native Installing webview-native requires a supported version of Node and Rust.

SnowflakeDev Community ❄️ 7 Nov 16, 2022
Node.js bindings to the ripgrep library, for fast file searching in JavaScript without child processes!

ripgrepjs ripgrepjs: Node.js bindings to the ripgrep library, for direct integration with JS programs without spawning an extra subprocess! This proje

Annika 1 May 10, 2022
Rust Blake hash bindings for Node.js.

@napi-rs/blake-hash Node.js binding for https://github.com/BLAKE3-team/BLAKE3. High performance, and no postinstall scripts. Support matrix node12 nod

LongYinan 35 Aug 12, 2022
Zero-cost high-level lua 5.3 wrapper for Rust

td_rlua This library is a high-level binding for Lua 5.3. You don't have access to the Lua stack, all you can do is read/write variables (including ca

null 47 May 4, 2022
Rust library to interface with Lua

hlua This library is a high-level binding for Lua 5.2. You don't have access to the Lua stack, all you can do is read/write variables (including callb

Pierre Krieger 488 Dec 26, 2022
Pure Rust Lua implementation

purua Pure Rust Lua implementation Usage $ bat lua_examples/defun.lua ───────┬────────────────────────────────────────── │ File: lua_examples/d

Kondo Uchio 35 Dec 28, 2021