Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
lucid-search
Advanced tools
Lucid is a stand-alone, zero-dependency, fast and lightweight library to highlight text and find matches.
npm i lucid-search --save
<script src="https://unpkg.com/lucid-search/dist/lucid-search.min.js"></script>
import {
findMatches,
} from 'lucid-search';
const haystack = 'The quick brown fox jumps over the lazy dog';
const needle = 'The dog';
const found = findMatches(haystack, needle);
console.log(found);
/*
{
mark: "<span class="matched">The</span> quick brown fox jumps over <span class="matched">the</span> lazy <span class="matched">dog</span>",
matches: (3) ["The", "the", "dog"]
}
*/
import {
findMatches,
} from 'lucid-search';
const haystack = 'The quick brown fox jumps over the lazy dog';
const needle = 'The dog';
/*
Due to performance you need to pass in the whole options object with "el" and "cssClass"
*/
const options = {
cssClass: 'found', // default is "marked"
el: 'mark', // default is "span"
};
const found = findMatches(haystack, needle, options);
console.log(found);
/*
{
mark: "<mark class="found">The</mark> quick brown fox jumps over <mark class="found">the</mark> lazy <mark class="found">dog</mark>",
matches: (3) ["The", "the", "dog"]
}
*/
Same like with ES6, only with lucidSearch
prefix:
// ...
const found = lucidSearch.findMatches(haystack, needle);
// ...
findMatches(haystack, needle, options)
findMatchesHtml(haystack, needle, options)
findMatchesNormalized(haystack, needle, options)
findMatchesHtmlNormalized(haystack, needle, options)
uncoverMatches(haystack, needles, options)
["the", "dog"]
as needleuncoverMatchesHtml(haystack, needles, options)
["the", "dog"]
as needleuncoverMatchesNormalized(haystack, needles, options)
["the", "dog"]
as needleuncoverMatchesHtmlNormalized(haystack, needles, options)
["the", "dog"]
as needlescore(matches, [haystack])
FAQs
Highlight text and find matches
We found that lucid-search demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.