byte-length

WebJar for byte-length

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

byte-length
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

byte-length
WebJar for byte-length
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/DylanPiercey/byte-length

Download byte-length

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/byte-length/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>byte-length</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/byte-length/
implementation 'org.webjars.npm:byte-length:1.0.2'
// https://jarcasting.com/artifacts/org.webjars.npm/byte-length/
implementation ("org.webjars.npm:byte-length:1.0.2")
'org.webjars.npm:byte-length:jar:1.0.2'
<dependency org="org.webjars.npm" name="byte-length" rev="1.0.2">
  <artifact name="byte-length" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='byte-length', version='1.0.2')
)
libraryDependencies += "org.webjars.npm" % "byte-length" % "1.0.2"
[org.webjars.npm/byte-length "1.0.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.


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!

Versions

Version
1.0.2