turn
minimal modules for a hypothetical es6 with lua's return, inspired by substack/mmmify and motivated by @shtylman.
syntax
Use import PATH
to load a module from the string PATH
. import
is a keyword
like typeof
that just returns an ordinary value.
Use return VALUE
in the top level scope to export functionality and jump
out of the current context.
example
// main.jsvar foo =console;
// foo.jsvar bar =return { return * 10 };
// bar.jsreturn { return n + 3 };
build it with browserify:
$ browserify -t turn main.js > bundle.js
then run it with node (or a browser):
$ node bundle.js
80
POW.
methods
var turn =
This module is a browserify transform but you don't need to use browserify necessarily to use it.
turn()
Return a through-stream desugaring the import
keyword and top level return
into require()
and module.exports=...
that can be parsed by node and browserify.
install
With npm do:
npm install turn
license
MIT