This commit is contained in:
11
node_modules/fuzzy/.editorconfig
generated
vendored
Normal file
11
node_modules/fuzzy/.editorconfig
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
; This file is for unifying the coding style for different editors and IDEs.
|
||||
; More information at http://EditorConfig.org
|
||||
|
||||
root = true
|
||||
|
||||
; All files should use two spaces and Unix line endings unless specified otherwise
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = LF
|
||||
20
node_modules/fuzzy/.jshintrc
generated
vendored
Normal file
20
node_modules/fuzzy/.jshintrc
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
// strictifying options
|
||||
"eqeqeq": true,
|
||||
"immed": true,
|
||||
"latedef": true,
|
||||
"forin": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"undef": true,
|
||||
"trailing": true,
|
||||
"node": true,
|
||||
|
||||
// Relaxing options
|
||||
"boss": true,
|
||||
"eqnull": true,
|
||||
"laxcomma": true,
|
||||
"expr": true,
|
||||
"strict": false,
|
||||
"predef": ["describe", "it", "xit"]
|
||||
}
|
||||
12
node_modules/fuzzy/.npmignore
generated
vendored
Normal file
12
node_modules/fuzzy/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
coverage.html
|
||||
.DS_Store
|
||||
node_modules
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
benchmark.js
|
||||
*.tgz
|
||||
Makefile
|
||||
test
|
||||
examples
|
||||
fuzzy-min.js
|
||||
test.js
|
||||
3
node_modules/fuzzy/.travis.yml
generated
vendored
Normal file
3
node_modules/fuzzy/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "6"
|
||||
22
node_modules/fuzzy/LICENSE-MIT
generated
vendored
Normal file
22
node_modules/fuzzy/LICENSE-MIT
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2012 Matt York
|
||||
|
||||
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.
|
||||
139
node_modules/fuzzy/README.md
generated
vendored
Normal file
139
node_modules/fuzzy/README.md
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
# fuzzy [](https://travis-ci.org/mattyork/fuzzy) [](https://badge.fury.io/js/fuzzy)
|
||||
|
||||
1k standalone fuzzy search / fuzzy filter a la Sublime Text's command-p fuzzy file search. Works in both node and browser.
|
||||
|
||||
[](http://htmlpreview.github.io/?https://github.com/mattyork/fuzzy/blob/master/examples/disney.html)
|
||||
|
||||
Try it yourself: [Disney Character Search Example](http://htmlpreview.github.io/?https://github.com/mattyork/fuzzy/blob/master/examples/disney.html)
|
||||
|
||||
## Get it
|
||||
|
||||
Node:
|
||||
|
||||
```bash
|
||||
$ npm install --save fuzzy
|
||||
$ node
|
||||
> var fuzzy = require('fuzzy');
|
||||
> console.log(fuzzy)
|
||||
{ test: [Function],
|
||||
match: [Function],
|
||||
filter: [Function] }
|
||||
```
|
||||
|
||||
Browser:
|
||||
|
||||
```html
|
||||
<script src="/path/to/fuzzy.js"></script>
|
||||
<script>
|
||||
console.log(fuzzy);
|
||||
// Object >
|
||||
// filter: function (pattern, arr, opts) {
|
||||
// match: function (pattern, string, opts) {
|
||||
// test: function (pattern, string) {
|
||||
</script>
|
||||
```
|
||||
|
||||
## Use it
|
||||
|
||||
Padawan: Simply filter an array of strings.
|
||||
|
||||
```javascript
|
||||
var list = ['baconing', 'narwhal', 'a mighty bear canoe'];
|
||||
var results = fuzzy.filter('bcn', list)
|
||||
var matches = results.map(function(el) { return el.string; });
|
||||
console.log(matches);
|
||||
// [ 'baconing', 'a mighty bear canoe' ]
|
||||
```
|
||||
|
||||
Jedi: Wrap matching characters in each string
|
||||
|
||||
```javascript
|
||||
var list = ['baconing', 'narwhal', 'a mighty bear canoe'];
|
||||
var options = { pre: '<', post: '>' };
|
||||
var results = fuzzy.filter('bcn', list, options)
|
||||
console.log(results);
|
||||
// [
|
||||
// {string: '<b>a<c>o<n>ing' , index: 0, score: 3, original: 'baconing'},
|
||||
// {string: 'a mighty <b>ear <c>a<n>oe', index: 2, score: 3, original: 'a mighty bear canoe'}
|
||||
// ]
|
||||
```
|
||||
|
||||
Jedi Master: sometimes the array you give is not an array of strings. You can
|
||||
pass in a function that creates the string to match against from each element
|
||||
in the given array
|
||||
|
||||
```javascript
|
||||
var list = [
|
||||
{rompalu: 'baconing', zibbity: 'simba'}
|
||||
, {rompalu: 'narwhal' , zibbity: 'mufasa'}
|
||||
, {rompalu: 'a mighty bear canoe', zibbity: 'saddam hussein'}
|
||||
];
|
||||
var options = {
|
||||
pre: '<'
|
||||
, post: '>'
|
||||
, extract: function(el) { return el.rompalu; }
|
||||
};
|
||||
var results = fuzzy.filter('bcn', list, options);
|
||||
var matches = results.map(function(el) { return el.string; });
|
||||
console.log(matches);
|
||||
// [ '<b>a<c>o<n>ing', 'a mighty <b>ear <c>a<n>oe' ]
|
||||
```
|
||||
|
||||
## Examples
|
||||
Check out the html files in the [examples](https://github.com/mattyork/fuzzy/tree/master/examples) directory.
|
||||
|
||||
Try the examples live:
|
||||
- [disney](http://htmlpreview.github.io/?https://github.com/mattyork/fuzzy/blob/master/examples/disney.html)
|
||||
- [wikipedia](http://htmlpreview.github.io/?https://github.com/mattyork/fuzzy/blob/master/examples/wikipedia.html)
|
||||
## Documentation
|
||||
[Code is well documented](https://github.com/mattyork/fuzzy/blob/master/lib/fuzzy.js) and the [unit tests](https://github.com/mattyork/fuzzy/blob/master/test/fuzzy.test.js) cover all functionality
|
||||
|
||||
## Contributing
|
||||
Fork the repo!
|
||||
|
||||
git clone <your_fork>
|
||||
cd fuzzy
|
||||
npm install
|
||||
make
|
||||
|
||||
Add unit tests for any new or changed functionality. Lint, test, and minify using make, then shoot me a pull request.
|
||||
|
||||
## Release History
|
||||
v0.1.0 - July 25, 2012
|
||||
|
||||
* Initial Release
|
||||
|
||||
v0.1.1 - September 19, 2015
|
||||
|
||||
* Fix broken links in package.json
|
||||
* Fix examples
|
||||
|
||||
v0.1.2 - September 25, 2016
|
||||
|
||||
* Exact matches get the highest score. #15
|
||||
* Add TypeScript typings #21
|
||||
* Better error handling for invalid input #13
|
||||
* Smaller bower install footprint #22
|
||||
|
||||
v0.1.3 - October 1, 2016
|
||||
|
||||
* Fix blocking bug in React Native #27
|
||||
|
||||
## License
|
||||
Copyright (c) 2015 Matt York
|
||||
Licensed under the MIT license.
|
||||
|
||||
## TODO
|
||||
|
||||
1. Search improvement: behave a bit more like sublime text by getting
|
||||
the BEST match in a given string, not just the first. For example,
|
||||
searching for 'bass' in 'bodacious bass' should match against 'bass',
|
||||
but it currently matches like so: `<b>od<a>ciou<s> ba<s>s`. There is
|
||||
a test already written, just need to implement it. Naive O(n^2) worst
|
||||
case: find every match in the string, then select the highest scoring
|
||||
match. Should benchmark this against current implementation once implemented
|
||||
Also, "reactive rice" would be `<r><e>active r<i><c>e`
|
||||
2. Search feature: Work on multiple strings in a match. For example, be able
|
||||
to match against 'stth' against an object { folder: 'stuff', file: 'thing' }
|
||||
3. Async batch updates so the UI doesn't block for huge sets. Or maybe Web Workers?
|
||||
4. Performance performance performance!
|
||||
33
node_modules/fuzzy/bower.json
generated
vendored
Normal file
33
node_modules/fuzzy/bower.json
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "fuzzy",
|
||||
"version": "0.1.1",
|
||||
"homepage": "https://github.com/mattyork/fuzzy",
|
||||
"authors": [
|
||||
"Matt York <york.matt@gmail.com>"
|
||||
],
|
||||
"description": "small, standalone fuzzy search / fuzzy filter like sublime text Cmd-P. browser or node.",
|
||||
"main": "lib/fuzzy.js",
|
||||
"keywords": [
|
||||
"fuzzy",
|
||||
"search",
|
||||
"filter",
|
||||
"sublime",
|
||||
"sublime text"
|
||||
],
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"mocha": ">= 1.3.0",
|
||||
"chai": ">= 1.1.1",
|
||||
"underscore": ">= 1.3.3",
|
||||
"uglify-js": ">= 1.3.2",
|
||||
"jshint": ">= 0.7.1"
|
||||
},
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests",
|
||||
"examples"
|
||||
]
|
||||
}
|
||||
33
node_modules/fuzzy/component.json
generated
vendored
Normal file
33
node_modules/fuzzy/component.json
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "fuzzy",
|
||||
"description": "small, standalone fuzzy search / fuzzy filter. browser or node",
|
||||
"version": "0.1.0",
|
||||
"homepage": "https://github.com/myork/fuzzy",
|
||||
"author": {
|
||||
"name": "Matt York",
|
||||
"email": "york.matt@gmail.com",
|
||||
"url": "mattyork.org"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/myork/fuzzy.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/myork/fuzzy/issues"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/myork/fuzzy/blob/master/LICENSE-MIT"
|
||||
}
|
||||
],
|
||||
"main": "lib/fuzzy.js",
|
||||
"scripts": [
|
||||
"lib/fuzzy.js"
|
||||
],
|
||||
"keywords": [
|
||||
"fuzzy",
|
||||
"search",
|
||||
"filter"
|
||||
]
|
||||
}
|
||||
58
node_modules/fuzzy/lib/fuzzy.d.ts
generated
vendored
Normal file
58
node_modules/fuzzy/lib/fuzzy.d.ts
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Return all elements of `array` that have a fuzzy match against `pattern`.
|
||||
*/
|
||||
export declare function simpleFilter(
|
||||
pattern: string,
|
||||
array: string[]
|
||||
): string[];
|
||||
|
||||
/**
|
||||
* Does `pattern` fuzzy match `inputString`?
|
||||
*/
|
||||
export declare function test(
|
||||
pattern: string,
|
||||
inputString: string
|
||||
): boolean;
|
||||
|
||||
export interface MatchOptions {
|
||||
pre?: string;
|
||||
post?: string;
|
||||
caseSensitive?: boolean;
|
||||
}
|
||||
|
||||
export interface MatchResult {
|
||||
rendered: string;
|
||||
score: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* If `pattern` matches `inputString`, wrap each matching character in `opts.pre`
|
||||
* and `opts.post`. If no match, return null.
|
||||
*/
|
||||
export declare function match(
|
||||
pattern: string,
|
||||
inputString: string,
|
||||
opts?: MatchOptions
|
||||
): MatchResult;
|
||||
|
||||
export interface FilterOptions<T> {
|
||||
pre?: string;
|
||||
post?: string;
|
||||
extract?(input: T): string;
|
||||
}
|
||||
|
||||
export interface FilterResult<T> {
|
||||
string: string;
|
||||
score: number;
|
||||
index: number;
|
||||
original: T;
|
||||
}
|
||||
|
||||
/**
|
||||
* The normal entry point. Filters `arr` for matches against `pattern`.
|
||||
*/
|
||||
export declare function filter<T>(
|
||||
pattern: string,
|
||||
arr: T[],
|
||||
opts?: FilterOptions<T>
|
||||
): FilterResult<T>[];
|
||||
144
node_modules/fuzzy/lib/fuzzy.js
generated
vendored
Normal file
144
node_modules/fuzzy/lib/fuzzy.js
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Fuzzy
|
||||
* https://github.com/myork/fuzzy
|
||||
*
|
||||
* Copyright (c) 2012 Matt York
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var root = this;
|
||||
|
||||
var fuzzy = {};
|
||||
|
||||
// Use in node or in browser
|
||||
if (typeof exports !== 'undefined') {
|
||||
module.exports = fuzzy;
|
||||
} else {
|
||||
root.fuzzy = fuzzy;
|
||||
}
|
||||
|
||||
// Return all elements of `array` that have a fuzzy
|
||||
// match against `pattern`.
|
||||
fuzzy.simpleFilter = function(pattern, array) {
|
||||
return array.filter(function(str) {
|
||||
return fuzzy.test(pattern, str);
|
||||
});
|
||||
};
|
||||
|
||||
// Does `pattern` fuzzy match `str`?
|
||||
fuzzy.test = function(pattern, str) {
|
||||
return fuzzy.match(pattern, str) !== null;
|
||||
};
|
||||
|
||||
// If `pattern` matches `str`, wrap each matching character
|
||||
// in `opts.pre` and `opts.post`. If no match, return null
|
||||
fuzzy.match = function(pattern, str, opts) {
|
||||
opts = opts || {};
|
||||
var patternIdx = 0
|
||||
, result = []
|
||||
, len = str.length
|
||||
, totalScore = 0
|
||||
, currScore = 0
|
||||
// prefix
|
||||
, pre = opts.pre || ''
|
||||
// suffix
|
||||
, post = opts.post || ''
|
||||
// String to compare against. This might be a lowercase version of the
|
||||
// raw string
|
||||
, compareString = opts.caseSensitive && str || str.toLowerCase()
|
||||
, ch;
|
||||
|
||||
pattern = opts.caseSensitive && pattern || pattern.toLowerCase();
|
||||
|
||||
// For each character in the string, either add it to the result
|
||||
// or wrap in template if it's the next string in the pattern
|
||||
for(var idx = 0; idx < len; idx++) {
|
||||
ch = str[idx];
|
||||
if(compareString[idx] === pattern[patternIdx]) {
|
||||
ch = pre + ch + post;
|
||||
patternIdx += 1;
|
||||
|
||||
// consecutive characters should increase the score more than linearly
|
||||
currScore += 1 + currScore;
|
||||
} else {
|
||||
currScore = 0;
|
||||
}
|
||||
totalScore += currScore;
|
||||
result[result.length] = ch;
|
||||
}
|
||||
|
||||
// return rendered string if we have a match for every char
|
||||
if(patternIdx === pattern.length) {
|
||||
// if the string is an exact match with pattern, totalScore should be maxed
|
||||
totalScore = (compareString === pattern) ? Infinity : totalScore;
|
||||
return {rendered: result.join(''), score: totalScore};
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
// The normal entry point. Filters `arr` for matches against `pattern`.
|
||||
// It returns an array with matching values of the type:
|
||||
//
|
||||
// [{
|
||||
// string: '<b>lah' // The rendered string
|
||||
// , index: 2 // The index of the element in `arr`
|
||||
// , original: 'blah' // The original element in `arr`
|
||||
// }]
|
||||
//
|
||||
// `opts` is an optional argument bag. Details:
|
||||
//
|
||||
// opts = {
|
||||
// // string to put before a matching character
|
||||
// pre: '<b>'
|
||||
//
|
||||
// // string to put after matching character
|
||||
// , post: '</b>'
|
||||
//
|
||||
// // Optional function. Input is an entry in the given arr`,
|
||||
// // output should be the string to test `pattern` against.
|
||||
// // In this example, if `arr = [{crying: 'koala'}]` we would return
|
||||
// // 'koala'.
|
||||
// , extract: function(arg) { return arg.crying; }
|
||||
// }
|
||||
fuzzy.filter = function(pattern, arr, opts) {
|
||||
if(!arr || arr.length === 0) {
|
||||
return [];
|
||||
}
|
||||
if (typeof pattern !== 'string') {
|
||||
return arr;
|
||||
}
|
||||
opts = opts || {};
|
||||
return arr
|
||||
.reduce(function(prev, element, idx, arr) {
|
||||
var str = element;
|
||||
if(opts.extract) {
|
||||
str = opts.extract(element);
|
||||
}
|
||||
var rendered = fuzzy.match(pattern, str, opts);
|
||||
if(rendered != null) {
|
||||
prev[prev.length] = {
|
||||
string: rendered.rendered
|
||||
, score: rendered.score
|
||||
, index: idx
|
||||
, original: element
|
||||
};
|
||||
}
|
||||
return prev;
|
||||
}, [])
|
||||
|
||||
// Sort by score. Browsers are inconsistent wrt stable/unstable
|
||||
// sorting, so force stable by using the index in the case of tie.
|
||||
// See http://ofb.net/~sethml/is-sort-stable.html
|
||||
.sort(function(a,b) {
|
||||
var compare = b.score - a.score;
|
||||
if(compare) return compare;
|
||||
return a.index - b.index;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
}());
|
||||
|
||||
46
node_modules/fuzzy/package.json
generated
vendored
Normal file
46
node_modules/fuzzy/package.json
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "fuzzy",
|
||||
"description": "small, standalone fuzzy search / fuzzy filter. browser or node",
|
||||
"version": "0.1.3",
|
||||
"homepage": "https://github.com/mattyork/fuzzy",
|
||||
"author": {
|
||||
"name": "Matt York",
|
||||
"email": "york.matt@gmail.com",
|
||||
"url": "mattyork.org"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/mattyork/fuzzy.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mattyork/fuzzy/issues"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/mattyork/fuzzy/blob/master/LICENSE-MIT"
|
||||
}
|
||||
],
|
||||
"main": "lib/fuzzy",
|
||||
"typings": "lib/fuzzy",
|
||||
"engines": {
|
||||
"node": ">= 0.6.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "./node_modules/.bin/mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": ">= 1.3.0",
|
||||
"chai": ">= 1.1.1",
|
||||
"underscore": ">= 1.3.3",
|
||||
"uglify-js": ">= 1.3.2",
|
||||
"jshint": ">= 0.7.1"
|
||||
},
|
||||
"keywords": [
|
||||
"fuzzy",
|
||||
"search",
|
||||
"filter",
|
||||
"sublime",
|
||||
"sublime text"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user