New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@stll/utf8-boundaries

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stll/utf8-boundaries

Shared Unicode text and streaming codec boundaries.

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
169K
972.12%
Maintainers
1
Weekly downloads
 
Created
Source

@stll/utf8-boundaries

Shared Unicode boundaries for streamed text and previews.

import { createTextReader, truncateGraphemes } from "@stll/utf8-boundaries";

const reader = createTextReader({ fatal: true, ignoreBOM: true });
const parts = chunks.map((chunk) => reader.read(chunk));
const text = parts.join("") + reader.finish();
const preview = truncateGraphemes(text, 100);

createTextReader keeps one decoder across reads. Call finish after the last chunk; finishPrefix deliberately omits an incomplete trailing scalar for a bounded preview. truncateCodePoints counts Unicode scalars; truncateGraphemes uses Intl.Segmenter to retain complete extended grapheme clusters.

The ./oxlint entry exports a default plugin with no-chunked-text-codec. The ./testing entry exports fast-check arbitraries for astral, combining, and RTL text around stream, 16 KiB, and 64 KiB boundaries, a complete boundary-case census, and assertTextRoundTrip for actual serializer/readback pairs. Fast-check is a peer needed only by this entry.

FAQs

Package last updated on 28 Oct 2026

Related posts