hustcc / word-width

:straight_ruler: word-width is simple browserjs / nodejs library for calculate ascii length of unicode string in terminal / console.

Home Page:http://git.hust.cc/word-width

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

word-width is simple browserjs / nodejs library for calculate ascii length of unicode string in terminal / console.

Inspired by jquast/wcwidth which is written by Python.

Build Status Coverage Status npm npm npm

1. Install

npm install --save word-width

2. Import It

  • Script tag.
<script type="text/javascript" src="dist/word-width.min.js"></script>
  • ES6 style.
var WordWidth = require('word-width');

//or

import WordWidth from 'word-width';

3. Usage & API

There is only one API named WordWidth(word).

// english
WordWidth('Hello Word Width!');       //17
  
// unicode
WordWidth('コンニチハ, セカイ!');      //19
WordWidth('越过长城,走向世界');       //18

4. Test

npm install

npm test

5. LICENSE

MIT

About

:straight_ruler: word-width is simple browserjs / nodejs library for calculate ascii length of unicode string in terminal / console.

http://git.hust.cc/word-width

License:MIT License


Languages

Language:JavaScript 93.1%Language:HTML 6.9%