@spare/lange
v0.16.16
Published
Get string length s.t. correcting astral codes and skipping ansi codes
Downloads
900
Readme
@spare/lange
A function returning string length, s.t. skipping ansi (escape) codes, correcting length of astral symbols.
Features
- ES2015 syntax
Install
$ npm install @spare/langeUsage
import { lange } from '@spare/lange'
const cast = [
'tolstoy',
'\u001b[3;4;31mhatsu\u001b[0m',
'\u{1F3C3}2\u{1F525}7',
]
for (let t of cast) {
console.log(`[${t}] [length] (${t.length}) [lange] (${lange(t)})`)
}Meta
Copyright (c) 2019-present, Haoyang (Vincent) Wang
