A nicer Node REPL.
The REPL will preload the lodash
library, available as ld
:
> ld.map([1, 2, 3], ld.identity);
Promise library bluebird
is provided as Promise
:
> var foo = function () { return Promise.resolve('bar'); };
To get the source code for a function, a src
function is provided:
> src(ld.map);
The console.log
function is provided as log
:
> log(someValue)
Load up all .js
files in a directory using the load() function, as follows:
> load('./src'); // must be relative path, and you can use glob patterns
The loaded variables reflect the directory structure:
> src.controllers.User.fetch('some-id');
That is too much to type, so let's get rid of the first part:
> load('./server', 1);
Now we don't have the 'server' as part of the variable:
> controllers.User.fetch('some-lead-id');
If you only care about a specific subdirectory, you can do:
> load('./src/controllers/special', 2);
Now access the loaded module:
> special.SpecialController.fetch('some-lead-id');
Combine the directory and the skip parameter to get desired result.
As you make changes to the files, use the reload() function to reload the modules, which will reflect all your changes:
> reload()
Call functions that return Promises just like a normal function call. The promises are resolved before continuing:
> var user = db.getUser('some-id') // db.getUser() returns a Promise
> user // Should print out the lead object
Uncaught exceptions will not crash the REPL. Instead, they simply get printed out, allowing further use of the REPL.