Files
klz-cables.com/.pnpm-store/v10/files/31/11fc84b7e05407d0ade7db9e97e707690cd0616f1bee052aedce8049965108efd50de13d8f94cb7d16854e83e6b11286957f055e12dffaf3393130217bea68
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

28 lines
813 B
Plaintext

# truncate-utf8-bytes [![build status](https://secure.travis-ci.org/parshap/truncate-utf8-bytes.svg?branch=master)](http://travis-ci.org/parshap/truncate-utf8-bytes)
Truncate a string to the given length in bytes. Correctly handles
multi-byte characters and surrogate pairs.
A browser implementation that doesn't use `Buffer.byteLength` is
provided to minimize build size.
## Example
```js
var truncate = require("truncate-utf8-bytes")
var str = "a☃" // a = 1 byte, ☃ = 3 bytes
console.log(truncate(str, 2))
// -> "a"
```
## API
### `var truncate = require("truncate-utf8-bytes")`
*When using browserify or webpack*, this automatically resolves to an
implementation that does not use `Buffer.byteLength`.
### `truncate(string, length)`
Returns `string` truncated to at most `length` bytes in length.