-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from alyon011/Development
Version 3.0
- Loading branch information
Showing
6 changed files
with
53 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Alexander Lyon | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,45 @@ | ||
# Haystack | ||
A Lightweight search plugin for JavaScript with zero dependencies | ||
<p align="center"> | ||
<img src="https://raw.githubusercontent.com/alyon011/Haystack/Development/assets/header.png" alt="Haystack"/> | ||
</p> | ||
|
||
Just provide the input form and the source data to search (as an array or object) | ||
## Overview: | ||
|
||
Haystack is a simple search / suggestion plugin that doesn't require any dependencies to run. Just provide a way for your users to enter their query and the source data to search (as an array or object), and Haystack will return a list of approximate matches. The lower the `flexibility` the more strict your matches will be. | ||
|
||
## To initialize Haystack: | ||
|
||
`const haystack = new Haystack({ | ||
```javascript | ||
const haystack = new Haystack({ | ||
caseSensitive: false, | ||
flexibility: 2, | ||
stemming: false, | ||
exclusions: /[0-9]+/g, | ||
ignoreStopWords: true | ||
});` | ||
}); | ||
``` | ||
|
||
## Methods: | ||
|
||
`haystack.search(searchTerm, source, [limit]);` | ||
```javascript | ||
haystack.search(searchTerm, source, [limit]); | ||
``` | ||
|
||
Returns either an array of matches within your `flexibility` range, or `null` if there are no matches. If no limit is given, the default length of results will be 1. | ||
|
||
```javascript | ||
haystack.tokenize(searchTerm, [delimiter]); | ||
``` | ||
|
||
`haystack.tokenize(searchTerm, [delimiter]);` | ||
By default this splits on whitespaces, but you can define a custom delimiter to use instead. | ||
|
||
## Features coming soon: | ||
|
||
Contributions and suggestions for improvement are always welcome! Some features planned for future versions include: | ||
|
||
- Recursive object property searching | ||
|
||
- Improved stemming | ||
|
||
## License | ||
|
||
MIT |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.