initial commit

This commit is contained in:
2026-03-22 03:21:45 +02:00
commit 897fea9f4e
15431 changed files with 2548840 additions and 0 deletions

21
node_modules/fuzzaldrin/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,21 @@
Copyright (c) 2009-2011 Joshaven Potter <yourtech@gmail.com>
Copyright (c) 2013 GitHub Inc.
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.

77
node_modules/fuzzaldrin/README.md generated vendored Normal file
View File

@@ -0,0 +1,77 @@
# fuzzaldrin
[![Build Status](https://travis-ci.org/atom/fuzzaldrin.svg?branch=master)](https://travis-ci.org/atom/fuzzaldrin)
[![Build status](https://ci.appveyor.com/api/projects/status/0ig71rjdgfm7y9c1/branch/master)](https://ci.appveyor.com/project/kevinsawicki/fuzzaldrin/branch/master)
Fuzzy filtering and string scoring.
This library is used by [Atom](http://atom.io) and so its focus will be on
scoring and filtering paths, methods, and other things common when writing code.
It therefore will specialize in handling common patterns in these types of
strings such as characters like `/`, `-`, and `_`, and also handling of
camel cased text.
## Using
```sh
npm install fuzzaldrin
```
### filter(candidates, query, [options])
Sort and filter the given candidates by matching them against the given query.
* `candidates` - An array of strings or objects.
* `query` - A string query to match each candidate against.
* `options` - An optional object with the following keys:
* `key` - The property to use for scoring if the candidates are objects.
* `maxResults` - The maximum numbers of results to return.
Returns an array of candidates sorted by best match against the query.
```coffee
{filter} = require 'fuzzaldrin'
# With an array of strings
candidates = ['Call', 'Me', 'Maybe']
results = filter(candidates, 'me')
console.log(results) # ['Me', 'Maybe']
# With an array of objects
candidates = [
{name: 'Call', id: 1}
{name: 'Me', id: 2}
{name: 'Maybe', id: 3}
]
results = filter(candidates, 'me', key: 'name')
console.log(results) # [{name: 'Me', id: 2}, {name: 'Maybe', id: 3}]
```
### score(string, query)
Score the given string against the given query.
* `string` - The string the score.
* `query` - The query to score the string against.
```coffee
{score} = require 'fuzzaldrin'
score('Me', 'me') # 0.17099999999999999
score('Maybe', 'me') # 0.0693
```
## Developing
```sh
git clone https://github.com/atom/fuzzaldrin.git
cd fuzzaldrin
npm install
npm test
```
You can run the benchmarks using:
```sh
npm run benchmark
```

45
node_modules/fuzzaldrin/lib/filter.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
(function() {
var pluckCandidates, scorer, sortCandidates;
scorer = require('./scorer');
pluckCandidates = function(a) {
return a.candidate;
};
sortCandidates = function(a, b) {
return b.score - a.score;
};
module.exports = function(candidates, query, queryHasSlashes, _arg) {
var candidate, key, maxResults, score, scoredCandidates, string, _i, _len, _ref;
_ref = _arg != null ? _arg : {}, key = _ref.key, maxResults = _ref.maxResults;
if (query) {
scoredCandidates = [];
for (_i = 0, _len = candidates.length; _i < _len; _i++) {
candidate = candidates[_i];
string = key != null ? candidate[key] : candidate;
if (!string) {
continue;
}
score = scorer.score(string, query, queryHasSlashes);
if (!queryHasSlashes) {
score = scorer.basenameScore(string, query, score);
}
if (score > 0) {
scoredCandidates.push({
candidate: candidate,
score: score
});
}
}
scoredCandidates.sort(sortCandidates);
candidates = scoredCandidates.map(pluckCandidates);
}
if (maxResults != null) {
candidates = candidates.slice(0, maxResults);
}
return candidates;
};
}).call(this);

80
node_modules/fuzzaldrin/lib/fuzzaldrin.js generated vendored Normal file
View File

@@ -0,0 +1,80 @@
(function() {
var PathSeparator, SpaceRegex, filter, matcher, scorer;
scorer = require('./scorer');
filter = require('./filter');
matcher = require('./matcher');
PathSeparator = require('path').sep;
SpaceRegex = /\ /g;
module.exports = {
filter: function(candidates, query, options) {
var queryHasSlashes;
if (query) {
queryHasSlashes = query.indexOf(PathSeparator) !== -1;
query = query.replace(SpaceRegex, '');
}
return filter(candidates, query, queryHasSlashes, options);
},
score: function(string, query) {
var queryHasSlashes, score;
if (!string) {
return 0;
}
if (!query) {
return 0;
}
if (string === query) {
return 2;
}
queryHasSlashes = query.indexOf(PathSeparator) !== -1;
query = query.replace(SpaceRegex, '');
score = scorer.score(string, query);
if (!queryHasSlashes) {
score = scorer.basenameScore(string, query, score);
}
return score;
},
match: function(string, query) {
var baseMatches, index, matches, queryHasSlashes, seen, _i, _ref, _results;
if (!string) {
return [];
}
if (!query) {
return [];
}
if (string === query) {
return (function() {
_results = [];
for (var _i = 0, _ref = string.length; 0 <= _ref ? _i < _ref : _i > _ref; 0 <= _ref ? _i++ : _i--){ _results.push(_i); }
return _results;
}).apply(this);
}
queryHasSlashes = query.indexOf(PathSeparator) !== -1;
query = query.replace(SpaceRegex, '');
matches = matcher.match(string, query);
if (!queryHasSlashes) {
baseMatches = matcher.basenameMatch(string, query);
matches = matches.concat(baseMatches).sort(function(a, b) {
return a - b;
});
seen = null;
index = 0;
while (index < matches.length) {
if (index && seen === matches[index]) {
matches.splice(index, 1);
} else {
seen = matches[index];
index++;
}
}
}
return matches;
}
};
}).call(this);

73
node_modules/fuzzaldrin/lib/matcher.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
(function() {
var PathSeparator;
PathSeparator = require('path').sep;
exports.basenameMatch = function(string, query) {
var base, index, lastCharacter, slashCount;
index = string.length - 1;
while (string[index] === PathSeparator) {
index--;
}
slashCount = 0;
lastCharacter = index;
base = null;
while (index >= 0) {
if (string[index] === PathSeparator) {
slashCount++;
if (base == null) {
base = string.substring(index + 1, lastCharacter + 1);
}
} else if (index === 0) {
if (lastCharacter < string.length - 1) {
if (base == null) {
base = string.substring(0, lastCharacter + 1);
}
} else {
if (base == null) {
base = string;
}
}
}
index--;
}
return exports.match(base, query, string.length - base.length);
};
exports.match = function(string, query, stringOffset) {
var character, indexInQuery, indexInString, lowerCaseIndex, matches, minIndex, queryLength, stringLength, upperCaseIndex, _i, _ref, _results;
if (stringOffset == null) {
stringOffset = 0;
}
if (string === query) {
return (function() {
_results = [];
for (var _i = stringOffset, _ref = stringOffset + string.length; stringOffset <= _ref ? _i < _ref : _i > _ref; stringOffset <= _ref ? _i++ : _i--){ _results.push(_i); }
return _results;
}).apply(this);
}
queryLength = query.length;
stringLength = string.length;
indexInQuery = 0;
indexInString = 0;
matches = [];
while (indexInQuery < queryLength) {
character = query[indexInQuery++];
lowerCaseIndex = string.indexOf(character.toLowerCase());
upperCaseIndex = string.indexOf(character.toUpperCase());
minIndex = Math.min(lowerCaseIndex, upperCaseIndex);
if (minIndex === -1) {
minIndex = Math.max(lowerCaseIndex, upperCaseIndex);
}
indexInString = minIndex;
if (indexInString === -1) {
return [];
}
matches.push(stringOffset + indexInString);
stringOffset += indexInString + 1;
string = string.substring(indexInString + 1, stringLength);
}
return matches;
};
}).call(this);

92
node_modules/fuzzaldrin/lib/scorer.js generated vendored Normal file
View File

@@ -0,0 +1,92 @@
(function() {
var PathSeparator, queryIsLastPathSegment;
PathSeparator = require('path').sep;
exports.basenameScore = function(string, query, score) {
var base, depth, index, lastCharacter, segmentCount, slashCount;
index = string.length - 1;
while (string[index] === PathSeparator) {
index--;
}
slashCount = 0;
lastCharacter = index;
base = null;
while (index >= 0) {
if (string[index] === PathSeparator) {
slashCount++;
if (base == null) {
base = string.substring(index + 1, lastCharacter + 1);
}
} else if (index === 0) {
if (lastCharacter < string.length - 1) {
if (base == null) {
base = string.substring(0, lastCharacter + 1);
}
} else {
if (base == null) {
base = string;
}
}
}
index--;
}
if (base === string) {
score *= 2;
} else if (base) {
score += exports.score(base, query);
}
segmentCount = slashCount + 1;
depth = Math.max(1, 10 - segmentCount);
score *= depth * 0.01;
return score;
};
exports.score = function(string, query) {
var character, characterScore, indexInQuery, indexInString, lowerCaseIndex, minIndex, queryLength, queryScore, stringLength, totalCharacterScore, upperCaseIndex, _ref;
if (string === query) {
return 1;
}
if (queryIsLastPathSegment(string, query)) {
return 1;
}
totalCharacterScore = 0;
queryLength = query.length;
stringLength = string.length;
indexInQuery = 0;
indexInString = 0;
while (indexInQuery < queryLength) {
character = query[indexInQuery++];
lowerCaseIndex = string.indexOf(character.toLowerCase());
upperCaseIndex = string.indexOf(character.toUpperCase());
minIndex = Math.min(lowerCaseIndex, upperCaseIndex);
if (minIndex === -1) {
minIndex = Math.max(lowerCaseIndex, upperCaseIndex);
}
indexInString = minIndex;
if (indexInString === -1) {
return 0;
}
characterScore = 0.1;
if (string[indexInString] === character) {
characterScore += 0.1;
}
if (indexInString === 0 || string[indexInString - 1] === PathSeparator) {
characterScore += 0.8;
} else if ((_ref = string[indexInString - 1]) === '-' || _ref === '_' || _ref === ' ') {
characterScore += 0.7;
}
string = string.substring(indexInString + 1, stringLength);
totalCharacterScore += characterScore;
}
queryScore = totalCharacterScore / queryLength;
return ((queryScore * (queryLength / stringLength)) + queryScore) / 2;
};
queryIsLastPathSegment = function(string, query) {
if (string[string.length - query.length - 1] === PathSeparator) {
return string.lastIndexOf(query) === string.length - query.length;
}
};
}).call(this);

39
node_modules/fuzzaldrin/package.json generated vendored Normal file
View File

@@ -0,0 +1,39 @@
{
"name": "fuzzaldrin",
"version": "2.1.0",
"description": "Fuzzy filtering and string scoring",
"licenses": [
{
"type": "MIT",
"url": "http://github.com/atom/fuzzaldrin/raw/master/LICENSE.md"
}
],
"main": "./lib/fuzzaldrin.js",
"scripts": {
"prepublish": "grunt prepublish",
"test": "grunt test",
"benchmark": "node_modules/.bin/coffee benchmark/benchmark.coffee"
},
"repository": {
"type": "git",
"url": "https://github.com/atom/fuzzaldrin.git"
},
"bugs": {
"url": "https://github.com/atom/fuzzaldrin/issues"
},
"homepage": "http://atom.github.io/fuzzaldrin",
"keywords": [
"fuzzy",
"filter",
"stringscore"
],
"devDependencies": {
"jasmine-focused": "1.x",
"grunt-contrib-coffee": "~0.9.0",
"grunt-cli": "~0.1.8",
"grunt": "~0.4.1",
"grunt-shell": "~0.2.2",
"grunt-coffeelint": "0.0.6",
"coffee-script": "~1.7"
}
}