Skip to content

node to luvit gotchas

radare edited this page Mar 13, 2012 · 2 revisions

While luvit has a similar api to node here are things to look for when converting code.

  • Arrays and Hashtables is a single variant type table
  • Arrays start at index 1
  • The directory catalog index.js is init.lua
  • path.exists, path.existsSync are fs.exists, fs.existsSync respectively
  • global is _G
  • Object reference must be passed to methods explicitly or use ':' operator. foo:bar() instead of foo.bar(foo)
  • node_modules/ directory corresponds to modules/
  • The CommonJS module and exports is not used. Simply return a value from a module:
-- equivalent to module.exports = {foo: bar}
return { foo = bar }
Clone this wiki locally