Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/cli.ts>charWidth

A JavaScript extension package for building strong and modern applications.
Latest
function charWidth
import { charWidth } from "https://deno.land/x/ayonli_jsext@v0.9.72/cli.ts";

Returns the width of a single character.

Examples

Example 1

import { charWidth } from "@ayonli/jsext/cli";

console.log(charWidth("a")); // 1
console.log(charWidth("你")); // 2
console.log(charWidth("👋")); // 2
console.log(charWidth("♥")); // 1

Parameters

char: string

Returns

1 | 2