Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tokuhirom/visualwidth-js
https://github.com/tokuhirom/visualwidth-js
Last synced: 18 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/tokuhirom/visualwidth-js
- Owner: tokuhirom
- License: mit
- Created: 2011-12-09T03:55:55.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2015-10-21T06:33:13.000Z (about 9 years ago)
- Last Synced: 2024-10-11T20:56:30.907Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 198 KB
- Stars: 18
- Watchers: 4
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.mkdn
- License: LICENSE
Awesome Lists containing this project
README
VisualWidth
===========This is a unicode character's visual width calculator for javascript.
This module supports node.js, too.
SYNOPSIS
--------var vw = require('./visualwidth');
console.log(vw('あいうabc')); # => 9
console.log(vw.width('あいうabc')); # => 9
console.log(vw.truncate('ほう。hasegawaさん', 7, '...')); # => "ほう..."
console.log(vw.substr('あいうabc', 1, 4)); # => "いうab"
console.log(vw.substring('あいうabc', 2, 4)); # => "うa"
console.log(vw.indexOf('あいうabc', 'a')); # => 6
console.log(vw.lastIndexOf('あいうabc', 'a')); # => 6)