source: trip-planner-front/node_modules/cli-width/README.md@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.8 KB
Line 
1# cli-width
2
3Get stdout window width, with four fallbacks, `tty`, `output.columns`, a custom environment variable and then a default.
4
5[![npm version](https://badge.fury.io/js/cli-width.svg)](http://badge.fury.io/js/cli-width)
6[![Build Status](https://travis-ci.org/knownasilya/cli-width.svg)](https://travis-ci.org/knownasilya/cli-width)
7[![Coverage Status](https://coveralls.io/repos/knownasilya/cli-width/badge.svg?branch=master&service=github)](https://coveralls.io/github/knownasilya/cli-width?branch=master)
8
9Tested against NodeJS v10+
10
11## Usage
12
13```
14npm install --save cli-width
15```
16
17```js
18"use strict";
19
20const cliWidth = require("cli-width");
21
22cliWidth(); // maybe 204 :)
23```
24
25You can also set the `CLI_WIDTH` environment variable.
26
27If none of the methods are supported, and the environment variable isn't set,
28the default width value is going to be `0`, that can be changed using the configurable `options`.
29
30## API
31
32### cliWidth([options])
33
34`cliWidth` can be configured using an `options` parameter, the possible properties are:
35
36- **defaultWidth**\<number\> Defines a default value to be used if none of the methods are available, defaults to `0`
37- **output**\<object\> A stream to be used to read width values from, defaults to `process.stdout`
38- **tty**\<object\> TTY module to try to read width from as a fallback, defaults to `require('tty')`
39
40### Examples
41
42Defining both a default width value and a stream output to try to read from:
43
44```js
45const cliWidth = require("cli-width");
46const ttys = require("ttys");
47
48cliWidth({
49 defaultWidth: 80,
50 output: ttys.output,
51});
52```
53
54Defines a different tty module to read width from:
55
56```js
57const cliWidth = require("cli-width");
58const ttys = require("ttys");
59
60cliWidth({
61 tty: ttys,
62});
63```
64
65## Tests
66
67```bash
68npm install
69npm test
70```
71
72Coverage can be generated with `npm run coverage`.
Note: See TracBrowser for help on using the repository browser.