https://github.com/hustcc/word-width
:straight_ruler: word-width is simple browserjs / nodejs library for calculate ascii length of unicode string in terminal / console.
https://github.com/hustcc/word-width
ascii ascii-width console terminal width word word-width
Last synced: about 1 month ago
JSON representation
:straight_ruler: word-width is simple browserjs / nodejs library for calculate ascii length of unicode string in terminal / console.
- Host: GitHub
- URL: https://github.com/hustcc/word-width
- Owner: hustcc
- License: mit
- Created: 2016-10-13T14:25:31.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-05T23:57:23.000Z (almost 8 years ago)
- Last Synced: 2025-02-28T19:11:56.904Z (about 2 months ago)
- Topics: ascii, ascii-width, console, terminal, width, word, word-width
- Language: JavaScript
- Homepage: http://git.hust.cc/word-width
- Size: 23.4 KB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [word-width](http://git.hust.cc/word-width/)
> **word-width** is simple browserjs / nodejs library for calculate ascii length of unicode string in terminal / console.
Inspired by [jquast/wcwidth](https://github.com/jquast/wcwidth) which is written by Python.
[](https://travis-ci.org/hustcc/word-width) [](https://coveralls.io/github/hustcc/word-width?branch=master) [](https://www.npmjs.com/package/word-width) [](https://www.npmjs.com/package/word-width) [](https://www.npmjs.com/package/word-width)
# 1. Install
> **npm install --save word-width**
# 2. Import It
- `Script` tag.
```html
```
- `ES6` style.
```js
var WordWidth = require('word-width');//or
import WordWidth from 'word-width';
```# 3. Usage & API
There is only one API named `WordWidth(word)`.
```js
// english
WordWidth('Hello Word Width!'); //17
// unicode
WordWidth('コンニチハ, セカイ!'); //19
WordWidth('越过长城,走向世界'); //18
```# 4. Test
> npm install
>
> npm test# 5. LICENSE
MIT