0.1.11-beta.0 • Published 4 years ago

unified-doc-search-regexp v0.1.11-beta.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

unified-doc-search-regexp

unified-doc search algorithm to return snippets with simple regular expression features.

Install

npm install unified-doc-search-regexp

Use

const content = 'a TO the b TO the c';

search(content, 'TO');
// [
  // { start: 2, end: 4, value: 'TO' },
  // { start: 11, end: 13, value: 'TO' },
// ];

search(content, 'TO', { isCaseSensitive: true });
// []

expect(search(content, 'a|b|c', { enableRegexp: true });
// [
//   { start: 0, end: 1, value: 'a' },
//   { start: 9, end: 10, value: 'b' },
//   { start: 18, end: 19, value: 'c' },
// ];

API

function SearchAlgorithm(
  content: string,
  query: string,
  options?: Options,
): SearchResult[]

Uses the SearchAlgorithm interface with options to configure regexp features. Performs the search algorithm against provided content and queryjk and returns an array of SearchResult.

Interfaces

interface Options {
  enableRegexp?: boolean;
  isCaseSensitive?: boolean;
}

interface SearchResult {
  start: number;
  end: number;
  value: string;
}
0.1.11-beta.0

4 years ago

0.1.10-beta.0

4 years ago

0.1.9-beta.0

4 years ago

0.1.8-beta.0

4 years ago

0.1.7-beta.0

4 years ago

0.1.6-beta.0

4 years ago

0.1.5-beta.0

4 years ago

0.1.4-beta.0

4 years ago

0.1.3-beta.0

4 years ago