byte-length
Get the real byte length of a string.
Last updated 8 years ago by dylanpiercey .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install byte-length 
SYNC missed versions from official npm registry.


Byte-Length
API Stability TypeScript Styled with prettier Build status Test Coverage NPM Version Downloads Browser Bundle Size

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-length

Example

import { byteLength } from "byte-length";

byteLength("hello"); //-> 5
byteLength("????"); //-> 4
byteLength("fullwidth characters"); //-> 60

Contributions

  • Use npm test to run tests.

Please feel free to create a PR!

Current Tags

  • 1.0.2                                ...           latest (8 years ago)

5 Versions

  • 1.0.2                                ...           8 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
  • 0.1.1                                ...           10 years ago
  • 0.1.0                                ...           11 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (12)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |