traceur-cli – wraps traceur cli to add repl and string eval
Experimental module to wrap the traceur-compiler cli to add REPL and functionality for doing string evaluations.
You can still use the original features as you'd expect.
Installation
npm install -g traceur-cli
REPL Examples
Fat arrows
➜ traceur-clitraceur> var f = => a * 2;undefinedtraceur> f4traceur>
➜ traceur-clitraceur> var f = =>
Iterators
➜ traceur-clitraceur> var foo =
➜ traceur-clitraceur> [
Destructuring
➜ traceur-clitraceur> var
Modules
➜ traceur-clitraceur> import
➜ traceur-clitraceur> var
Computed Property Names
➜ traceur-clitraceur> var x = 0;undefinedtraceur> var obj = ;<unknown file>:1:23: Unexpected token ;,<unknown file>:1:25: Unexpected token }traceur> var obj =
REPL Functions
You can use regular Node repl functions as .save
and .load
.
➜ traceur-clitraceur> .help.break Sometimes you get stuck, this gets you out.clear Alias
Eval Examples
➜ traceur-cli -e '({ foo: "bar", bar: "bat" });'
➜ traceur-cli -e 'var { foo, bar } = {foo: "Some", bar: "Data"}; console.log(foo + " " + bar)'Some Dataundefined
➜ traceur-cli -e '({ foo: "bar", bar: "bat" });' > test.txt➜ cat test.txt
➜ traceur-cli -e 'console.log("hello"); var foo = "Bar"; console.log(foo); foo;'helloBarBar
➜ traceur-cli -e '(for (x of [1, 2, 3, 4]) "Foo: " + x).next()'
Pipeing
➜ echo '({ foo: "bar", bar: "bat" });' | traceur-clitraceur> ;
Original usage of traceur
You can use the traceur-cli as a wrapper for the original functionality of traceur.
For instance by using -h
:
➜ traceur-cli -h Usage: traceur-cli [options] [files] Commands: # [...etc]
Or compiling files:
➜ traceur-cli --script example.js --out compiled.js➜ node compiled.js
TODO
Make it work with iterators.Add support for multiline/blocks- ~~Add support for modules/requires in repl. (Has now basic support.)~
- Tests