Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 3, 2024 via pnpm

cli-width 3.0.0

Get stdout window width, with two fallbacks, tty and then a default.
Package summary
Share
0
issues
1
license
1
ISC
Package created
21 Jan 2015
Version published
14 Apr 2020
Maintainers
2
Total deps
1
Direct deps
0
License
ISC

Issues

0
This package has no issues

Licenses

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
cli-width@3.0.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of cli-width 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does cli-width do?

Cli-width is a handy tool that helps developers obtain the stdout window width in JavaScript. It uses four fallback mechanisms - tty, output.columns, a custom environment variable and a default, to ensure it provides a width even if certain features are unavailable. This makes it highly reliable for defining layout dimensions in terminal-based applications.

How do you use cli-width?

In order to integrate Cli-width, first, install the package to your project using npm with the following command:

npm install --save cli-width

After installation, use it in your JavaScript file by requiring the library and calling the function:

const cliWidth = require('cli-width');

cliWidth(); // Returns the current width. For example, it might return 204.

Beyond basic reading of window width, Cli-width offers configurable options. For instance, you can set a default width value and a stream output to try to read from:

const cliWidth = require('cli-width');
const ttys = require('ttys');

cliWidth({
  defaultWidth: 80,
  output: ttys.output,
});

To configure a different tty module from which to read width, perform the following:

const cliWidth = require('cli-width');
const ttys = require('ttys');

cliWidth({
  tty: ttys,
});

Cli-width also allows for environment value settings using the CLI_WIDTH variable.

Where are the cli-width docs?

The official documentation of Cli-width, including the APIs and usage details, is on the GitHub repository page - git+ssh://git@github.com/knownasilya/cli-width.git. The GitHub README contains several practical examples to ease integration and usage of Cli-width in a variety of scenarios.