node_modules ignore

This commit is contained in:
oier committed 2025-05-08 23:43:47 +02:00
1 parent e19d52f172
commit 4574544c9f
65041 files changed
+10593536

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
suite('lunr.Builder', function () {
var documents = [{
id: 'a',
title: 'Mr. Green kills Colonel Mustard',
body: 'Mr. Green killed Colonel Mustard in the study with the candlestick. Mr. Green is not a very nice fellow.',
wordCount: 19
},{
id: 'b',
title: 'Plumb waters plant',
body: 'Professor Plumb has a green plant in his study',
wordCount: 9
},{
id: 'c',
title: 'Scarlett helps Professor',
body: 'Miss Scarlett watered Professor Plumbs green plant while he was away from his office last week.',
wordCount: 16
}]
this.add('build', function () {
lunr(function () {
this.ref('id')
this.field('title')
this.field('body')
documents.forEach(function (doc) {
this.add(doc)
}, this)
})
})
})
+26
View File
@@ -0,0 +1,26 @@
var lunr = require('../lunr.js'),
Benchmark = require('benchmark'),
wordList = require('word-list'),
fs = require('fs')
var suite = function (name, fn) {
var s = new Benchmark.Suite(name, {
onStart: function (e) { console.log(e.currentTarget.name) },
onCycle: function (e) { console.log(" " + String(e.target)) },
onError: function (e) { console.error(e.target.error) }
})
fn.call(s, s)
s.run()
}
var words = fs.readFileSync(wordList, 'utf-8')
.split('\n')
.slice(0, 1000)
.sort()
global.lunr = lunr
global.Benchmark = Benchmark
global.suite = suite
global.words = words
+43
View File
@@ -0,0 +1,43 @@
suite('lunr.Pipeline', function () {
var tokenToToken = function(token) {
return token
}
var tokenToTokenArray = function(token) {
return [token, token]
}
var buildTokens = function(count) {
return words.slice(0, count).map(function(word) {
return new lunr.Token(word)
})
}
lunr.Pipeline.registerFunction(tokenToToken, 'tokenToToken')
lunr.Pipeline.registerFunction(tokenToTokenArray, 'tokenToTokenArray')
var fewTokens = buildTokens(50);
var manyTokens = buildTokens(1000)
var tokenToTokenPipeline = new lunr.Pipeline
tokenToTokenPipeline.add(tokenToToken)
var tokenToTokenArrayPipeline = new lunr.Pipeline
tokenToTokenArrayPipeline.add(tokenToTokenArray)
this.add('few tokens, token -> token', function () {
tokenToTokenPipeline.run(fewTokens)
})
this.add('many tokens, token -> token', function () {
tokenToTokenPipeline.run(manyTokens)
})
this.add('few tokens, token -> token array', function () {
tokenToTokenArrayPipeline.run(fewTokens)
})
this.add('many tokens, token -> token array', function () {
tokenToTokenArrayPipeline.run(manyTokens)
})
})
+24
View File
@@ -0,0 +1,24 @@
suite('lunr.QueryParser', function () {
var parse = function (q) {
var query = new lunr.Query (['title', 'body']),
parser = new lunr.QueryParser(q, query)
parser.parse()
}
this.add('simple', function () {
parse('foo bar')
})
this.add('field', function () {
parse('title:foo bar')
})
this.add('modifier', function () {
parse('foo~2 bar')
})
this.add('complex', function () {
parse('title:foo~2^6 bar')
})
})
+72
View File
@@ -0,0 +1,72 @@
suite('search', function () {
var documents = [{
id: 'a',
title: 'Mr. Green kills Colonel Mustard',
body: 'Mr. Green killed Colonel Mustard in the study with the candlestick. Mr. Green is not a very nice fellow.',
wordCount: 19
},{
id: 'b',
title: 'Plumb waters plant',
body: 'Professor Plumb has a green plant in his study',
wordCount: 9
},{
id: 'c',
title: 'Scarlett helps Professor',
body: 'Miss Scarlett watered Professor Plumbs green plant while he was away from his office last week.',
wordCount: 16
}]
var idx = lunr(function () {
this.ref('id')
this.field('title')
this.field('body')
documents.forEach(function (doc) {
this.add(doc)
}, this)
})
this.add('single term', function () {
idx.search('green')
})
this.add('multi term', function () {
idx.search('green plant')
})
this.add('trailing wildcard', function () {
idx.search('pl*')
})
this.add('leading wildcard', function () {
idx.search('*ant')
})
this.add('contained wildcard', function () {
idx.search('p*t')
})
this.add('with field', function () {
idx.search('title:plant')
})
this.add('edit distance', function () {
idx.search('plint~2')
})
this.add('typeahead', function () {
idx.query(function (q) {
q.term("pl", { boost: 100, usePipeline: true })
q.term("pl", { boost: 10, usePipeline: false, wildcard: lunr.Query.wildcard.TRAILING })
q.term("pl", { boost: 1, editDistance: 1 })
})
})
this.add('negated query', function () {
idx.search('-plant')
})
this.add('required term', function () {
idx.search('green +plant')
})
})
+7
View File
@@ -0,0 +1,7 @@
suite('lunr.stemmer', function () {
this.add('#call', function () {
for (var i = 0; i < words.length; i++) {
lunr.stemmer(new lunr.Token (words[i]))
}
})
})
+42
View File
@@ -0,0 +1,42 @@
suite('lunr.TokenSet', function () {
var tokenSet = lunr.TokenSet.fromArray([
'january', 'february', 'march', 'april',
'may', 'june', 'july', 'august',
'september', 'october', 'november', 'december'
].sort())
var noWildcard = lunr.TokenSet.fromString('september')
var withWildcard = lunr.TokenSet.fromString('*ber')
this.add('.fromArray', function () {
lunr.TokenSet.fromArray(words)
})
this.add('.fromString (no wildcard)', function () {
lunr.TokenSet.fromString('javascript')
})
this.add('.fromString (with wildcard)', function () {
lunr.TokenSet.fromString('java*cript')
})
this.add('.fromFuzzyString', function () {
lunr.TokenSet.fromFuzzyString('javascript', 2)
})
this.add('#toArray', function () {
tokenSet.toArray()
})
this.add('#toString', function () {
tokenSet.toString()
})
this.add('#intersect (no wildcard)', function () {
tokenSet.intersect(noWildcard)
})
this.add('#intersect (with wildcard)', function () {
tokenSet.intersect(withWildcard)
})
})
+7
View File
@@ -0,0 +1,7 @@
suite('lunr.tokenizer', function () {
var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"
this.add('#call', function () {
lunr.tokenizer(lorem)
})
})
+31
View File
@@ -0,0 +1,31 @@
suite('lunr.Vector', function () {
var index, val
var v1 = new lunr.Vector,
v2 = new lunr.Vector
for (var i = 0; i < 1000; i++) {
index = Math.floor(i + Math.random() * 100)
val = Math.random() * 100
v1.insert(i, val)
}
for (var i = 0; i < 1000; i++) {
index = Math.floor(i + Math.random() * 100)
val = Math.random() * 100
v2.insert(i, val)
}
this.add('magnitude', function () {
v1.magnitude()
})
this.add('dot', function () {
v1.dot(v2)
})
this.add('similarity', function () {
v1.similarity(v2)
})
})