1.0.3 • Published 7 years ago

lazy-search v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Lazy-search

NPM version GitHub issues Travis

With just a little typing, you can find exactly what you want from your contents! This library is implemented with a search function similar to the directory search used in Intellij.

npm.io

Installation

The easiest way to install lazy-search is with npm.

npm i lazy-search

Alternately, download the source.

git clone https://github.com/stegano/lazy-search.git

API

LazySearch.prototype.find(contents, searchKeyword) : Object[]

  • contents: You can enter content such as the content of a news article or a file path or anything.
  • searchKeyword: Keyword to search, search keywords do not have to be exact.

Examples

You can search even if your query is not correct, like the code below.

var lazySearch = new LazySearch();
var contents = "Ttttest apple eeeee";
var mySearchKeyword = "aple"; // <- You probably wanted to search for "Apple" :)
var result = lazySearch.find(contents, mySearchKeyword); // -> [{"_rawData":[{"char":"a","index":8},{"char":"p","index":9},{"char":"l","index":11},{"char":"e","index":12}],"contents":"apple","distance":1}]

Result: Object[]

  • _rawData: LazySearch performs a search for each character. Store the character's position in _rawData.
    • char: The character found in the content.
    • index: The position of the character in the contents.
  • contents: The string that most matches the search keyword.
  • distance: The closer the search keyword is, the closer the distance value is to 1.

Docs

Create an API document using JSDoc.

npm install
npm run doc

Tests

To run the test suite, first install the dependencies, then run npm test

npm ininstall
npm test
1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago