n.
Version:
Node REPL with some modules bundled
62 lines (44 loc) • 1.17 kB
Markdown
# n.
Node.js REPL with lodash and moment
## Why?
Sometimes we use the Node.js REPL interface to experiment with code.
Wouldn’t it be great to have that interface with some modules required by default?
## Installation
```shell
$ npm install -g n.
```
__NOTES__
Do not forget the `.` after `n`!
## Usage
```shell
$ n.
n. >
```
## attached modules
- loadash is now attached to the REPL context as `_`, so just use it:
```shell
n. > _.compact([0, 1, false, 2, '', 3]);
[ 1, 2, 3 ]
n. >
```
- moment is now attached to the REPL context as `m`, so just use it:
```shell
n. > m.format('x')
'1451783998074'
n. >
```
__Note:__
The `_` and `m` characters is special in the Node REPL (see [nodejs.org/api/repl.html](http://nodejs.org/api/repl.html#repl_repl_features)).
**n.** redirects those special variables to `$` per default, but you can set your own using the environment variable `SPECIAL_VAR` like this:
```shell
$ SPECIAL_VAR=my_var n.
n. > 123
123
n. > my_var
123
n. >
```
Also note that using the command `.clear` you clear the context lodash is bound to.
Enjoy!
# Acknowledgement
Most of code copied from [n_](https://github.com/borisdiakur/n_).