Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wasmoon

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wasmoon

There is nothing to see here

  • 1.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
451
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Wasmoon

This package aims to provide a way to:

  • Embed Lua to any Node.js, Deno and modern browsers.
  • Run lua code in any operational system

Installation

Globally via npm
$: npm install -g wasmoon

This will install wasmoon globally so that it may be run from the command line anywhere.

Running on-demand:

Using npx you can run the script without installing it first:

$: npx wasmoon

CLI Usage

Wasmoon by default reads and execute code from stdin, but you can force it to read from file passing the -f argument:

$: wasmoon -f file.lua

Api documentation

To initialize wasmoon on your project:

const { Lua } = require('wasmoon')
await Lua.ensureInitialization()

Create a new Lua state, register the standard library, set a global variable, execute a code and get a global variable:

const state = new Lua();

try {
    state.registerStandardLib();
    state.setGlobal('sum', (x, y) => x + y);
    state.doString(`
    print(sum(10, 10))
    function multiply(x, y)
        return x * y
    end
    `);
    const multiply = state.getGlobal('multiply');
    console.log(multiply(10, 10))
} finally {
    state.close();
}

Keywords

FAQs

Package last updated on 06 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc