slice-ansi is a Node.js utility that slices strings containing ANSI escape codes, such as those produced by chalk. It lets you extract a substring by visible column indexes while keeping grapheme clusters intact and excluding partial clusters at the end boundary.
Project status
- Actively maintained, with the most recent update on 2026-04-04 (v9.0.0, upstream push also on 2026-04-04), and no evidence of long-term dormancy.
- Apparent update cadence, v8.0.0 on 2026-02-10, then v9.0.0 on 2026-04-04 (about 2 months), suggesting ongoing development though it has been roughly 4 months since the latest update relative to 2026-08-12.
AI summary generated
Recent updates
v9.0.0
v9.0.0 updates slice-ansi to require Node.js 22, and changes `endSlice` so that wide grapheme clusters are excluded when they would cross the `endSlice` boundary, aligning behavior with `startSlice`. Internally, the implementation was substantially refactored around token application and hyperlink handling, and tests were added to cover wide grapheme and hyperlink edge cases.
Breakingv8.0.0
v8.0.0 updates slice-ansi with grapheme-safe slicing and adds hyperlink-aware slicing (OSC 8). The implementation was largely refactored around a new ANSI/OSC tokenizer and now more carefully parses terminal control sequences while slicing.
BreakingFeaturesv7.1.2
v7.1.2 is a small patch release that (per the release notes) addresses a vulnerability from v7.1.1. The actual code changes are minimal and appear to be a refactor in ANSI parsing, plus a package.json metadata tweak.
Securityv7.1.0
This release adds TypeScript declaration files for the slice-ansi package. It also updates package metadata so tooling can discover the types and adjusts the package test command.
BreakingFeaturesv7.0.0
v7.0.0 primarily updates the project’s supported runtime environment and tooling. Release notes document a Node.js 18 requirement, while the actual diff also changes CI node coverage and bumps at least one production dependency major version.
Breakingv6.0.0
v6.0.0 focuses on performance improvements and raises the supported Node.js versions. The codebase was also significantly refactored internally around ANSI escape tokenization and reduction, which changes how the function emits closing SGR codes when slicing styled strings.
BreakingFeaturesv5.0.0
v5.0.0 primarily shifts slice-ansi to a pure ESM package targeting Node.js >= 12. The implementation also changes some internals and bumps multiple runtime dependencies, but only the Node engine requirement and ESM migration are mentioned in the release notes.
Breakingv4.0.0
v4.0.0 raises the minimum supported Node.js version to 10 and updates how slice length is computed for fullwidth characters when the `endSlice` argument is omitted. It also stops normalizing the input string (removing `String.prototype.normalize()` usage).
Breakingv3.0.0
v3.0.0 requires Node.js >= 8 and significantly rewrites slice-ansi's ANSI parsing/slicing logic. Besides the documented fixes for extra escapes and background/foreground handling, the implementation changes how ANSI codes are tracked and how closing/reset escape sequences are generated.
Breakingv2.1.0
v2.1.0 adds support for slicing strings that contain true color (24-bit) ANSI escape sequences. The change is implemented in the core ANSI parsing logic and is backed by a new test case.
Features