keylight
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

To highlight some key content with color

demo

  • demo1 demo1
  • demo2 demo2

usage

// install
yarn add keylight
 
// import 
import keylight from 'keylight'
 
// use
const kl = new keylight('#f701bc')
const content = "hello world"
const key = "hello"
const hightContent = kl.match(content, key)
// => '<span style="color:#f701bc;">hello</span> world'
 
// change color
kl.color = '#ababab'
const hightContent = kl.match(content, key)
// => '<span style="color:#ababab;">hello</span> world'
 
// additional operating
const upperCase = val => val.toUpperCase()
const hightContent = kl.match(content, key, uppercase) 
// => '<span style="color:#ababab;">HELLO</span> world'
 

Package Sidebar

Install

npm i keylight

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

129 kB

Total Files

15

Last publish

Collaborators

  • naeco