{ "name": "string-width", "description": "Get the visual width of a string - the number of columns required to display it", "dist-tags": { "latest": "5.1.2", "version4": "4.2.3" }, "versions": { "2.1.1": { "name": "string-width", "version": "2.1.1", "description": "Get the visual width of a string - the number of columns required to display it", "license": "MIT", "repository": { "type": "git", "url": "git+https://github.com/sindresorhus/string-width.git" }, "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=4" }, "scripts": { "test": "xo && ava" }, "files": [ "index.js" ], "dependencies": { "is-fullwidth-code-point": "^2.0.0", "strip-ansi": "^4.0.0" }, "devDependencies": { "ava": "*", "xo": "*" }, "gitHead": "74d8d552b465692790c41169b123409669d41079", "bugs": { "url": "https://github.com/sindresorhus/string-width/issues" }, "_id": "string-width@2.1.1", "_npmVersion": "5.0.0", "_nodeVersion": "8.0.0", "dist": { "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "shasum": "ab93f27a8dc13d28cac815c462143a6d9012ae9e", "tarball": "http://localhost:4260/string-width/string-width-2.1.1.tgz" }, "directories": {} }, "4.2.3": { "name": "string-width", "version": "4.2.3", "description": "Get the visual width of a string - the number of columns required to display it", "license": "MIT", "repository": { "type": "git", "url": "git+https://github.com/sindresorhus/string-width.git" }, "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=8" }, "scripts": { "test": "xo && ava && tsd" }, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" }, "devDependencies": { "ava": "^1.4.1", "tsd": "^0.7.1", "xo": "^0.24.0" }, "readme": "# string-width\n\n> Get the visual width of a string - the number of columns required to display it\n\nSome Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.\n\nUseful to be able to measure the actual width of command-line output.\n\n\n## Install\n\n```\n$ npm install string-width\n```\n\n\n## Usage\n\n```js\nconst stringWidth = require('string-width');\n\nstringWidth('a');\n//=> 1\n\nstringWidth('古');\n//=> 2\n\nstringWidth('\\u001B[1m古\\u001B[22m');\n//=> 2\n```\n\n\n## Related\n\n- [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module\n- [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string\n- [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string\n\n\n---\n\n