ec-highlighter-core

1.0.5 • Public • Published

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

/ec-highlighter-core/

    Package Sidebar

    Install

    npm i ec-highlighter-core

    Weekly Downloads

    8

    Version

    1.0.5

    License

    ISC

    Unpacked Size

    3.08 kB

    Total Files

    4

    Last publish

    Collaborators

    • nishanthshankar