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

luaworker

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

luaworker

Package for running a Lua VM in a Web Worker.

  • 0.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Lua Worker

Package for running a Lua VM in a Web Worker.

Example

If you prebuilt the worker.js file, you can specify its location when calling the luaworker module function:

var lua = require('luaworker')('worker.js');
lua.execute('name = "Lua"');
lua.execute('print("Hello from " .. name .. "!")', function (err, buffer) {
  console.log(buffer);
});

To be able to run this in a browser, you need to use a framework that supports CommonJS modules (for example: Browserify).

Using this package

To get the necessary files from this package, install it with NPM:

npm install --save luaworker

As stated above, you need to first package this code so that it can run in a browser. You can do this with, for example, Browserify.

Here's how you'd create the JavaScript files to run in your browser, assuming you are using the code in the Example section above:

# Bundle the Worker code into its own file:
browserify node_modules/luaworker/worker.js -o worker.js
# Put the code from the Example section into main.js, then run this:
browserify main.js -o app.js

If you run this, you should see the output "Hello from Lua!" in your console.

Note that this hasn't been optimized yet, so if you don't minimize your code (by using UglifyJS, for example), you may end up with a huge worker.js file.

Building

To build the required JavaScript, you need to have Emscripten in your PATH. To build, simply run ./build.

The work in emlua.patch is borrowed from kripken's lua.vm.js.

Note: This does not include the Lua → JS bridge, since allowing access to JavaScript from Lua might not always be desirable.

FAQs

Package last updated on 10 Mar 2014

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