1.0.5 • Published 2 years ago

ec-highlighter-core v1.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

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} 
] 
*/