1.0.8 • Published 4 years ago
robust-search v1.0.8
Robust Search
Package details at: robust-search or https://www.npmjs.com/package/robust-search
Description
It's a robust and flexible search component.
Objective
It allows for an almost match, i.e., "Jenna" wouldn't equal "jena", but now it can. So it's objective it's to give more tools to compare, taking into account user's human mistakes
Usage
For the complete documentation, click here
Install
Browser
<script src="https://cdn.jsdelivr.net/npm/robust-search/index.js"></script>Node.js
npm i --save-dev robust-searchImport
Without this, it won't work
import {
equal,
different,
almost,
unalike,
isMatch,
search,
exclude,
contains
} from "robust-search"String.prototype.equal
Is a string the same as another?
// String equal
"test".equal("test") // returns true
// String equal
"test".equal("tset") // returns falseString.prototype.diff, or different
Is a string not the same as another?
// String not equal
"test".diff("tset") // returns trueString.prototype.almost
Is a string almost same as another?
// String almost
"test".almost("tset") // returns trueString.prototype.unalike
Is a string not quite the same as another?
// String unalike
"test".unalike("tset") // returns falseString.prototype.isMatch
This will use all of the above to check for a match
// String isMatch (does an almost or equal)
"test".isMatch("tset") // returns trueString.prototype.contains
Does it contain the substring given? Sort of an includes
// String contains
"test".contains("est") // returns true
// String doesn't contain
"test".contains("tset") // returns falsesearch
Searchs using the above methods inside an array
// String search
search([ "test", "hello", "world!" ], "test") // returns ["test"]exclude
Searchs for non-matches using the above methods inside an array
// String exclude
exclude([ "test", "hello", "world!" ], "test") // returns ["hello", "world!"]