パッケージの詳細

n_

borisdiakur1.1kMIT4.0.1

lodash REPL

_, cli, console, lodash

readme

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 (2024-02-07)

  • fix: support node 20

4.0.0 (2023-02-12)

  • BREAKING CHANGE: drop support for ancient node versions (< 18)

3.0.0 (2020-07-16)

2.0.2 (2019-09-22)

  • lodash upgrade to v4.17.15

2.0.1 (2019-05-05)

  • fix: os-homedir related deprecation warning

2.0.0 (2019-05-04)

  • BREAKING CHANGE: drop support for old lodash version (3.x) and ancient node versions (< 6.x)
  • BREAKING CHANGE: drop support for enabling strict mode via environment variable NODE_REPL_MODE

1.4.8 (2019-05-02)

  • fix: rli related deprecation warning

1.4.7 (2019-04-04)

  • lodash upgrade to v4.17.11

1.4.6 (2018-07-29)

  • added package-lock.json

1.4.5 (2017-08-20)

  • fix: install on windows (resolves #21)

1.4.4 (2017-01-08)

  • fix: all additional lodash versions are now stored in the folder extraneous (resolves #19)

1.4.3 (2016-12-22)

  • fix: $ n_3 --fp now throws as FP-mode does not exist in lodash@3.10.1.

1.4.2 (2016-12-22)

  • fix: using tar.gz package to “manually” unpack lodash@3 instead of npm-install-version

1.4.1 (2016-12-22)

  • fix: bin entry n_3 was missing in package.json

1.4.0 (2016-12-22)

  • n_ additionally includes lodash@^3.10.1 selectable via n_3

1.3.0 (2016-03-18)

  • n_ stores its session history under ~/.n_repl_history

1.2.0 (2016-03-16)

  • you can now enable FP mode via $ n_ --fp

1.1.0 (2016-01-26)

  • you can now enable strict mode via $ n_ --use_strict or $ NODE_REPL_MODE=strict n_ in Node.js >= 4.x

1.0.0 (2016-01-13)

  • lodash upgrade to v4.0.0

0.0.8 (2015-08-13)

  • you can now define a custom special variable via $ SPECIAL_VAR=my_var n_ (see #13)
  • added CHANGELOG.md