4.0.1 • Published 1 year ago

n_ v4.0.1

Weekly downloads
209
License
MIT
Repository
github
Last release
1 year ago

n_

Node.js REPL with lodash

Coverage Status

animated gif showing usage of n_

Why?

Sometimes we use the Node.js REPL interface to experiment with code. Wouldn’t it be great to have that interface with lodash required by default?

Installation

$ npm install -g n_

Usage

$ n_
n_ >

lodash is now attached to the REPL context as _, so just use it:

n_ > _.compact([0, 1, false, 2, '', 3]);
[ 1, 2, 3 ]
n_ >

FP mode

Use lodash's functional programming variant lodash/fp:

$ n_ --fp
n_ > _.map(function(v) { return v * 2; }, [1, 2, 3]);
[ 2, 4, 6 ]
n_ >

Strict mode

Enable strict mode:

$ n_ --use_strict
n_ >

Repl specificities

Commands

Commands which facilitate changing the lodash flavor can be executed with the .lodash repl command:

  • .lodash fp: switch to lodash/fp
  • .lodash vanilla: switch to vanilla lodash mode
  • .lodash reset: switch to initial lodash mode
  • .lodash swap: switch to the other lodash mode (vanilla/fp)
  • .lodash current: output current lodash flavor in use
  • .lodash version: output lodash version in use

Use .lodash help to view the available repl commands within the repl.

__ as last evaluated expression

The special character _ refers to the lodash instance, and cannot hold the value of the last expression. Use __ to access the last expression instead:

n_ > 10 + 2
12
n_ > 'number ' + __
'number 12'

Configuration options

Aside from --fp and --use_strict/--use-strict, other options are available either as CLI flags or via environment variables (with a trailing _N_).

Available cli options can be viewed with:

n_ --help

Enjoy! :rocket:

4.0.1

1 year ago

4.0.0

2 years ago

3.0.1

3 years ago

3.0.0

5 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.4.8

6 years ago

1.4.7

6 years ago

1.4.6

7 years ago

1.4.5

8 years ago

1.4.4

8 years ago

1.4.3

8 years ago

1.4.2

8 years ago

1.4.1

8 years ago

1.4.0

8 years ago

1.3.1

9 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago