CommonJS
'use strict'
const wcwidth = require('@stackline/wcwidth')
console.log(wcwidth('A字🤦🏼♂️e\u0301'))
console.log(wcwidth.config({ control: -1 })('line one\nline two'))
Maintained compatibility package
Measure terminal columns with a callable historical API, reproducible Unicode 17.0.0 tables, and grapheme-aware emoji widths.
Browse sourceStart here
npm install @stackline/wcwidth@1.0.0
'use strict'
const wcwidth = require('@stackline/wcwidth')
console.log(wcwidth('A字🤦🏼♂️e\u0301'))
console.log(wcwidth.config({ control: -1 })('line one\nline two'))
import wcwidth, { unicodeVersion } from '@stackline/wcwidth'
console.log(wcwidth('🇨🇦'))
console.log(unicodeVersion)
Compatibility
The package root remains a function named wcwidth with one argument and no nested default property.
config({ nul, control }) preserves the historical defaults, object fill, inheritance, retained mutation, and control-width behavior.
A native ESM default plus named config and unicodeVersion exports have conditional TypeScript declarations.
The production install contains one package node with zero runtime, optional, peer, or bundled dependencies.
The runnable CommonJS example above includes strict control-character configuration.
Deterministic data
| Input category | Columns |
|---|---|
| Combining and zero-width characters | 0 |
| East Asian Wide and Fullwidth characters | 2 |
| East Asian Ambiguous characters | 1 |
| Flags, keycaps, emoji presentation and qualifying emoji ZWJ clusters | 2 per grapheme cluster |
| Ordinary scalar values | 1 |
Generated tables come from checksum-pinned Unicode 17.0.0 sources. Results do not depend on the host Node.js ICU version.
Adoption
An npm alias lets existing require('wcwidth') imports remain unchanged.
{
"dependencies": {
"wcwidth": "npm:@stackline/wcwidth@1.0.0"
}
}
Run a clean install and the downstream test, type, build, and snapshot suites. Review output containing emoji, combining text, CJK, or characters added after the historical Unicode tables.
Release evidence
Verification guide · Full compatibility contract · Migration guide · Security policy
This package is independently maintained and is not affiliated with or endorsed by Tim Oxley, Jun Woong, Markus Kuhn, the original project, or the Unicode Consortium. Original and Unicode attribution is preserved.