strind
Partition strings based on character indices.
Install
yarn add strind
Usage
; const result = ; console;/** * { matched: ['b', 'cd'], unmatched: [ { chars: 'a', index: 0 } ] } * */
Callback
An optional callback function can be passed as the third argument.
The function is called with the substring chars
and boolean matches
if the substring matches the array indices.
; const result = ; console;/** * [ { isHighlighted: false, text: 'a' }, { isHighlighted: true, text: 'b' }, { isHighlighted: true, text: 'cd' } ] * */