1.0.2 • Published 8 years ago
byte-length v1.0.2
Calculate the real byte length of any string.
Why
In node many will use Buffer.byteLength, however including the entire buffer shim in the browser just for getting the byte length of a string is not very conservative.
Installation
npm install byte-lengthExample
import { byteLength } from "byte-length";
byteLength("hello"); //-> 5
byteLength("😀"); //-> 4
byteLength("fullwidth characters"); //-> 60Contributions
- Use
npm testto run tests.
Please feel free to create a PR!