npm

n.

0.0.2 • Public • Published

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

$ npm install -g n.

NOTES Do not forget the . after n!

Usage

$ n.
n. >

attached modules

  • loadash is now attached to the REPL context as _, so just use it:
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:
n. > m.format('x')
'1451783998074'
n. >

Note:

The _ and m characters is special in the Node REPL (see nodejs.org/api/repl.html).

n. redirects those special variables to $ per default, but you can set your own using the environment variable SPECIAL_VAR like this:

$ 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_.

Package Sidebar

Install

npm i n.

Weekly Downloads

9

Version

0.0.2

License

MIT

Last publish

Collaborators

  • eggcaker