prc b6c02717e6 Upload complete no-internet building environment. | преди 1 година | |
---|---|---|
.. | ||
.gitmodules | преди 1 година | |
.npmignore | преди 1 година | |
.travis.yml | преди 1 година | |
AUTHORS | преди 1 година | |
README.md | преди 1 година | |
browser.js | преди 1 година | |
index.js | преди 1 година | |
package.json | преди 1 година | |
test.js | преди 1 година |
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.
var getLength = require("utf8-byte-length")
console.log(truncate("a☃", 2)) // a = 1 byte, ☃ = 3 bytes
// -> 4
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.