Truncate a string to the given length in bytes. Correctly handles multi-byte characters and surrogate pairs.
A browser implementation that doesn't use
provided to minimize build size.
var truncate =var str = "a☃" // a = 1 byte, ☃ = 3 bytesconsole// -> "a"
var truncate = require("truncate-utf8-bytes")
When using browserify or webpack, this automatically resolves to an
implementation that does not use
string truncated to at most
length bytes in length.