match-highlight-texts
No matter what JavaScript-based framework you use, you can always use this package to highlight words entered by the user.
Installation
npm install --save match-highlight-texts
Usage
; const list = "Hello world, this is match-highlight-texts";const query = "world light";;/* [ { item: "Hello ", highlight: false }, { item: "world", highlight: true }, { item: ", this is match-high", highlight: false }, { item: "light", highlight: true }, { item: "-texts", highlight: false } ]*/
Advanced options
[string]
delimiter: It splits the query string by one space
Default: ' '
const list = "Hello world, this is match-highlight-texts";const query = "world;light";;/* [ { item: "Hello ", highlight: false }, { item: "world", highlight: true }, { item: ", this is match-high", highlight: false }, { item: "light", highlight: true }, { item: "-texts", highlight: false } ]*/
[boolean]
caseSensitive: Default: false
const list = "Hello world, hello match-highlight-texts";const query = "hello";;/* [ { item: "Hello world, ", highlight: false }, { item: "hello", highlight: true }, { item: " match-highlight-texts", highlight: false } ]*/
LICENSE
MIT