Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. cli-width
  2. =========
  3. Get stdout window width, with four fallbacks, `tty`, `output.columns`, a custom environment variable and then a default.
  4. [![npm version](https://badge.fury.io/js/cli-width.svg)](http://badge.fury.io/js/cli-width)
  5. [![Build Status](https://travis-ci.org/knownasilya/cli-width.svg)](https://travis-ci.org/knownasilya/cli-width)
  6. [![Coverage Status](https://coveralls.io/repos/knownasilya/cli-width/badge.svg?branch=master&service=github)](https://coveralls.io/github/knownasilya/cli-width?branch=master)
  7. ## Usage
  8. ```
  9. npm install --save cli-width
  10. ```
  11. ```js
  12. 'use strict';
  13. var cliWidth = require('cli-width');
  14. cliWidth(); // maybe 204 :)
  15. ```
  16. You can also set the `CLI_WIDTH` environment variable.
  17. If none of the methods are supported, and the environment variable isn't set,
  18. the default width value is going to be `0`, that can be changed using the configurable `options`.
  19. ## API
  20. ### cliWidth([options])
  21. `cliWidth` can be configured using an `options` parameter, the possible properties are:
  22. - **defaultWidth**\<number\> Defines a default value to be used if none of the methods are available, defaults to `0`
  23. - **output**\<object\> A stream to be used to read width values from, defaults to `process.stdout`
  24. - **tty**\<object\> TTY module to try to read width from as a fallback, defaults to `require('tty')`
  25. ### Examples
  26. Defining both a default width value and a stream output to try to read from:
  27. ```js
  28. var cliWidth = require('cli-width');
  29. var ttys = require('ttys');
  30. cliWidth({
  31. defaultWidth: 80,
  32. output: ttys.output
  33. });
  34. ```
  35. Defines a different tty module to read width from:
  36. ```js
  37. var cliWidth = require('cli-width');
  38. var ttys = require('ttys');
  39. cliWidth({
  40. tty: ttys
  41. });
  42. ```
  43. ## Tests
  44. ```bash
  45. npm install
  46. npm test
  47. ```
  48. Coverage can be generated with `npm run coverage`.