{"id":15383617,"url":"https://github.com/knownasilya/cli-width","last_synced_at":"2025-08-06T15:28:02.441Z","repository":{"id":428869,"uuid":"29607910","full_name":"knownasilya/cli-width","owner":"knownasilya","description":"Fallback to a default if `process.stdout.getWindowSize` doesn't exist","archived":false,"fork":false,"pushed_at":"2024-06-27T03:45:12.000Z","size":620,"stargazers_count":24,"open_issues_count":2,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-07T20:02:16.372Z","etag":null,"topics":["cli","cli-width","tty"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/knownasilya.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"knownasilya"}},"created_at":"2015-01-21T19:44:35.000Z","updated_at":"2024-08-13T16:03:31.000Z","dependencies_parsed_at":"2024-09-16T22:17:00.293Z","dependency_job_id":"97d3d391-d15c-4fe6-ad6f-bf3c26dc7acc","html_url":"https://github.com/knownasilya/cli-width","commit_stats":{"total_commits":70,"total_committers":14,"mean_commits":5.0,"dds":0.6714285714285715,"last_synced_commit":"a5b9ad0af43a103cccfacfdc83fd82792c1371cd"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/knownasilya/cli-width","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knownasilya%2Fcli-width","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knownasilya%2Fcli-width/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knownasilya%2Fcli-width/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knownasilya%2Fcli-width/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knownasilya","download_url":"https://codeload.github.com/knownasilya/cli-width/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knownasilya%2Fcli-width/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269103432,"owners_count":24360349,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-06T02:00:09.910Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","cli-width","tty"],"created_at":"2024-10-01T14:38:55.159Z","updated_at":"2025-08-06T15:28:02.384Z","avatar_url":"https://github.com/knownasilya.png","language":"JavaScript","funding_links":["https://github.com/sponsors/knownasilya"],"categories":[],"sub_categories":[],"readme":"# cli-width\n\nGet stdout window width, with four fallbacks, `tty`, `output.columns`, a custom environment variable and then a default.\n\n[![npm version](https://badge.fury.io/js/cli-width.svg)](http://badge.fury.io/js/cli-width)\n[![Coverage Status](https://coveralls.io/repos/knownasilya/cli-width/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/knownasilya/cli-width?branch=master)\n\nTested against Node v12 to v20.\nIncludes TypeScript types.\n\n## Usage\n\n```\nnpm install --save cli-width\n```\n\n```js\nconst cliWidth = require('cli-width');\n\ncliWidth(); // maybe 204 :)\n```\n\nYou can also set the `CLI_WIDTH` environment variable.\n\nIf none of the methods are supported, and the environment variable isn't set,\nthe default width value is going to be `0`, that can be changed using the configurable `options`.\n\n## API\n\n### cliWidth([options])\n\n`cliWidth` can be configured using an `options` parameter, the possible properties are:\n\n- **defaultWidth**\\\u003cnumber\\\u003e Defines a default value to be used if none of the methods are available, defaults to `0`\n- **output**\\\u003cobject\\\u003e A stream to be used to read width values from, defaults to `process.stdout`\n- **tty**\\\u003cobject\\\u003e TTY module to try to read width from as a fallback, defaults to `require('tty')`\n\n### Examples\n\nDefining both a default width value and a stream output to try to read from:\n\n```js\nconst cliWidth = require('cli-width');\nconst ttys = require('ttys');\n\ncliWidth({\n  defaultWidth: 80,\n  output: ttys.output,\n});\n```\n\nDefines a different tty module to read width from:\n\n```js\nconst cliWidth = require('cli-width');\nconst ttys = require('ttys');\n\ncliWidth({\n  tty: ttys,\n});\n```\n\n## Tests\n\n```bash\nnpm install\nnpm test\n```\n\nCoverage can be generated with `npm run coverage`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknownasilya%2Fcli-width","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknownasilya%2Fcli-width","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknownasilya%2Fcli-width/lists"}