n_
lodash REPL
Last updated a month ago by borisdiakur .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install n_ 
SYNC missed versions from official npm registry.

n_

Node.js REPL with lodash

Build Status Coverage Status npm version JavaScript Style Guide

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

It is possible to 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

It is possible to enable strict mode in Node.js >= 4.x:

$ n_ --use_strict
n_ >

Repl specificities

Commands

Some commands are available to facilitate some operations, and are host under .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

and the .lodash help to have more details about lodash repl commands

__ as last evaluated expression

Special character _ refer to the lodash instance, and cannot hold value of last expression. To provide the same feature, __ was introduced:

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

Configuration options

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

The two main feature you can control is History persistance and Prompt Theme.

Flag aliases Env variable Description Default
--history-path --history, history-file _N_HISTORY_PATH Location of repl history file ~/.n_repl_history
--prompt.symbol _N_PROMPT__SYMBOL Symbol to use as $ prompt >
--prompt.name _N_PROMPT__NAME Name for the prompt n_
--prompt.color.name _N_PROMPT__COLOR__NAME Color for prompt name n_ blue
--prompt.color.symbol _N_PROMPT__COLOR__SYMBOL Color for prompt symbol red
--prompt.color.flavor _N_PROMPT__COLOR__FLAVOR Color for section of prompt about lodash flavor in use cyan
--prompt.color.help _N_PROMPT__COLOR__HELP Color for section of prompt about lodash flavor in use green

About styling, valid colors are: black, red, green, yellow, blue, magenta, cyan, white,gray, and dim.


Enjoy! :rocket:

Current Tags

  • 3.0.0                                ...           latest (a month ago)

26 Versions

  • 3.0.0                                ...           a month ago
  • 2.0.2                                ...           a year ago
  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.4.8                                ...           a year ago
  • 1.4.7                                ...           a year ago
  • 1.4.6                                ...           2 years ago
  • 1.4.5                                ...           3 years ago
  • 1.4.4                                ...           4 years ago
  • 1.4.3                                ...           4 years ago
  • 1.4.2                                ...           4 years ago
  • 1.4.1                                ...           4 years ago
  • 1.4.0                                ...           4 years ago
  • 1.3.1                                ...           4 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
  • 0.0.8                                ...           5 years ago
  • 0.0.7                                ...           5 years ago
  • 0.0.6                                ...           6 years ago
  • 0.0.5                                ...           6 years ago
  • 0.0.4                                ...           6 years ago
  • 0.0.3                                ...           6 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 19
Dependencies (4)
Dev Dependencies (10)

Copyright 2014 - 2016 © taobao.org |