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

demoon

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

demoon - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

.github/workflows/publish.yml

4

package.json
{
"name": "demoon",
"version": "0.0.1",
"version": "0.0.2",
"description": "Lua + Node",

@@ -16,4 +16,4 @@ "main": "src/index.js",

"dependencies": {
"wasmoon": "1.5.0"
"wasmoon": "1.6.1"
}
}

@@ -1,1 +0,52 @@

# demoon
# demoon
You love Lua but the runtime API is very weak and you don't want to handle and learn a lot of different luarock libraries? You came at the right place! This project aims to offer the bests of **Lua** and **NodeJS** together.
## Usage
You don't need `lua` installed to run demoon, but you need `node` and npm as well, firstly, install demoon globally:
```sh
$: npm i -g demoon
```
Then run it passing your entry lua file:
```sh
$: demoon app.lua
```
## Example
This is a little sample code to demonstrate how demoon is powerful and bridges well with nodeJS:
```lua
-- you can require node modules (package.json/node_modules works as well)
local http = require('http')
-- you can require js modules and lua files
-- require('./myjsmodule.js')
-- require('./myluamodule.lua')
local port = os.getenv('PORT') or 8080
function sleep(ms)
-- you can use and create promises
return Promise.create(function(resolve)
setTimeout(resolve, ms)
end)
end
-- top level await works!
sleep(1000):await()
http.createServer(async(function (req, res)
-- you can await inside async bounded functions
sleep(1000):await()
res:write('Hello World!');
-- because end is a lua keyword you have to put the '_'
res:_end();
end)):listen(port);
print('Your server is running on port ' .. port .. '!')
```

@@ -1,6 +0,5 @@

const { LuaFactory, decorate } = require('wasmoon')
const { LuaFactory } = require('wasmoon')
const path = require('path')
const { walk } = require('./file')
const fs = require('fs').promises
const proxy = require('./proxy')

@@ -21,26 +20,17 @@ const registerDirectory = async (factory, dir) => {

lua.global.set('new', constructor => new constructor)
lua.global.set('global', decorate(global, {
reference: true,
metatable: proxy
}))
lua.global.set('new', (constructor, ...args) => new constructor(...args))
lua.global.set('global', global)
lua.global.set('mountFile', factory.mountFileSync.bind(factory))
lua.global.set('jsRequire', (modulename, metaDirectory) => {
if (modulename.startsWith('.')) {
modulename = path.resolve(metaDirectory, '..', modulename)
}
if (modulename.startsWith('.')) {
modulename = path.resolve(metaDirectory, '..', modulename)
}
return decorate(require(modulename), {
reference: true,
metatable: proxy
return require(modulename)
})
})
const module = await factory.getModule()
module.module.FS.chdir(process.cwd())
await lua.doFile(path.resolve(__dirname, "std/main.lua"))
await lua.doFile(entryFile)
await lua.doFile(path.resolve(process.cwd(), entryFile))
}
module.exports = { start }

Sorry, the diff of this file is not supported yet

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