unstale

npm / highlight-words-core

highlight-words-core

What changed in highlight-words-core 2, from its official release notes, upgrade guides and advisories. Also covers @types/highlight-words-core. Sources checked 2026-10-19.

10 breaking4 new APIs and options2 behavior and defaults6 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli 0.2.0 on npm

highlight-words-core 222 changes

Breaking changes 10

  • String search words are matched literally by default. Use RegExp search words to match patterns, or set autoEscape to false for trusted input.

    2.0.0release notes

  • Chunk is a union of highlighted and non-highlighted chunks; check chunk.highlight before reading searchIndex, and use literal highlight values when constructing chunks.

    2.0.0release notes

  • combineChunks no longer sorts its input array in place and always returns new chunk objects.

    2.0.0release notes

  • Published code uses modern JavaScript syntax instead of ES5 output; older environments and bundlers that cannot parse it need to transpile the package.

    2.0.0release notes

  • findChunks and combineChunks no longer include a highlight property in returned chunks; final chunks from findAll and fillInChunks still do.

    2.0.0release notes

  • Custom findChunks functions must include searchIndex in each returned chunk, identifying the matching word's index within searchWords.

    2.0.0release notes

  • Custom findChunks functions receive searchWords as a ReadonlyArray; mutable-array parameter declarations must be updated.

    2.0.0release notes

  • The package ships CommonJS and ES module builds and defines exports, so only the package root can be imported; deep imports and previously published src/*.js files are unavailable.

    2.0.0release notes

  • Non-string search words from untyped callers are matched as strings instead of being skipped when falsy.

    2.0.0release notes

  • The package is written in TypeScript and ships TypeScript declarations; Flow types are no longer included.

    2.0.0release notes

New APIs and options 4

  • HighlightedChunk is an exported type for highlighted chunks.

    2.0.0release notes

  • NonHighlightedChunk is an exported type for non-highlighted chunks.

    2.0.0release notes

  • Highlighted chunks include searchIndex, the index within searchWords of the matching search word.

    2.0.0release notes

  • searchWords can include RegExp objects, which are used as-is with their own flags.

    2.0.0release notes

Behavior and default changes 2

  • With autoEscape false, invalid regular-expression string search words are matched literally instead of throwing an error.

    2.0.0release notes

  • When sanitize changes text, it is applied character by character so matches can map back to the original text; context-dependent sanitizers can produce different results.

    2.0.0release notes

Fixes and other changes 6

  • Custom findChunks results extending outside the text or ending before they start no longer produce invalid or overlapping chunks.

    2.0.0release notes

  • Matches map back to the original text when sanitize changes its length.

    2.0.0release notes

  • searchWords can be a readonly array, such as an array declared with as const.

    2.0.0release notes

  • Missing searchWords values no longer throw an error; nothing is highlighted.

    2.0.0release notes

  • Surrogate pairs, such as emoji, are no longer split between chunks.

    2.0.0release notes

  • Missing textToHighlight values are no longer searched as strings such as "undefined".

    2.0.0release notes