node_repl

1 view
Skip to first unread message

r...@tinyclouds.org

unread,
Sep 10, 2009, 2:14:40 PM9/10/09
to nodejs
Here's a fun script

#!/usr/bin/env node
node.stdio.open();
function prompt () {
print("node-" + node.version + "> ");
}
prompt();
node.stdio.addListener("data", function (cmd) {
try {
var result = eval(cmd);
puts("=> " + JSON.stringify(result) + "\n");
} catch (e) {
puts("!! Error: " + e.message);
}
prompt();
});

addListener("exit", function () {
puts("\n\ngoodbye\n");
});


Works well with rlwrap.

Jeremy Apthorp

unread,
Sep 10, 2009, 6:44:23 PM9/10/09
to nod...@googlegroups.com
Can you make node run that when it's given no arguments on the
command-line (python-style)?

Jeremy



2009/9/11 <r...@tinyclouds.org>:

Felix Geisendörfer

unread,
Sep 10, 2009, 6:53:33 PM9/10/09
to nodejs
Oh my! This is awesome! Node is awesome. I also didn't know about
rlwrap - good stuff!

Thanks for sharing this!
-- Felix Geisendörfer aka the_undefined

Felix Geisendörfer

unread,
Sep 10, 2009, 6:54:06 PM9/10/09
to nodejs
+1
Reply all
Reply to author
Forward
0 new messages