ec-highlighter-core
v1.0.5
Published
Highlight text in UI. Split the text into arrays based on a search string.
Downloads
23
Maintainers
Readme
Installation
npm i ec-highlighter-core
API
Split the text into arrays based on a search string needed for highlighting in the UI The module is exported as a function. This function search a text for a string and returns an array of objects. The object has the text key and the match key.
import getParts from 'ec-highlighter-core'
const textToSearch = 'Javascript is developer friendly'
const searchPhrase = 'IS'
console.log('OUTPUT:', getParts(textToSearch, searchPhrase))
/*
OUPUT: [
{text:"Javascript ", match: false},
{text:"is", match: true},
{text:" developer friendly", match: false}
]
*/