By default, this module defers to
Buffer.byteLength. A browser implementation is also provided that doesn't use
Buffer.byteLengthminimize build size.
var getLength = require("utf8-byte-length") console.log(truncate("a☃", 2)) // a = 1 byte, ☃ = 3 bytes // -> 4
When using browserify or webpack, this automatically resolves to an
implementation that does not use
var getLength = require("utf8-byte-length")
Returns the byte length of
string. Throws an error if
stringis not a string.