Derived from visualwidth-js this package identifies the size of one characterCode in terminals
npm install wcsize


wcsize is a JavaScript CommonJS package that deals with the fact that some characters in monospace font environments (like terminals) are displayed with the size of two characters while others occupy the space of one character.It is derived (forked) from wcwidth which is a derivate of wcwidth.c which is custom implemented and seems better tested with japanese than the similar package visualwidth-js. It differes from both of those packages by only returning the width of one character (as integer!) which is important for performance
reasons.
This is a sister-package of monospace-char-width whis is based on visualwidth-js.
npm i wcsize --save and pass the character you want to test like this:``JavaScript
var wcsize = require('wcsize')
function charSize(string, pos) {
wcsize(string.charCodeAt(pos), pos > 0 ? string.charCodeAt(pos-1) : 0)
}
charSize('abcd', 0) // 1
``