chuwanghui 6d115466a5 electron库 преди 6 години
..
.gitmodules 6d115466a5 electron库 преди 6 години
.npmignore 6d115466a5 electron库 преди 6 години
.travis.yml 6d115466a5 electron库 преди 6 години
AUTHORS 6d115466a5 electron库 преди 6 години
README.md 6d115466a5 electron库 преди 6 години
browser.js 6d115466a5 electron库 преди 6 години
index.js 6d115466a5 electron库 преди 6 години
package.json 6d115466a5 electron库 преди 6 години
test.js 6d115466a5 electron库 преди 6 години

README.md

utf8-byte-length build status

Get the utf8 byte length of a string, taking into account multi-byte characters and surrogate pairs.

By default, this module defers to Buffer.byteLength. A browser implementation is also provided that doesn't use Buffer.byteLength minimize build size.

Example

var getLength = require("utf8-byte-length")
console.log(truncate("a☃", 2)) // a = 1 byte, ☃ = 3 bytes
// -> 4

API

var getLength = require("utf8-byte-length")

When using browserify or webpack, this automatically resolves to an implementation that does not use Buffer.byteLength.

getLength(string)

Returns the byte length of string. Throws an error if string is not a string.