Socket
Socket
Sign inDemoInstall

lunr

Package Overview
Dependencies
0
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.0.1

9

lib/builder.js

@@ -33,3 +33,3 @@ /*!

this._fields = []
this.invertedIndex = {}
this.invertedIndex = Object.create(null)
this.documentTermFrequencies = {}

@@ -148,7 +148,8 @@ this.documentLengths = {}

if (this.invertedIndex[term] == undefined) {
var posting = { "_index": this.termIndex }
var posting = Object.create(null)
posting["_index"] = this.termIndex
this.termIndex += 1
for (var k = 0; k < this._fields.length; k++) {
posting[this._fields[k]] = {}
posting[this._fields[k]] = Object.create(null)
}

@@ -161,3 +162,3 @@

if (this.invertedIndex[term][fieldName][docRef] == undefined) {
this.invertedIndex[term][fieldName][docRef] = {}
this.invertedIndex[term][fieldName][docRef] = Object.create(null)
}

@@ -164,0 +165,0 @@

@@ -137,3 +137,3 @@ /*!

var query = new lunr.Query(this.fields),
matchingDocuments = {},
matchingDocuments = Object.create(null),
queryVector = new lunr.Vector

@@ -140,0 +140,0 @@

@@ -39,3 +39,3 @@ /*!

lunr.Pipeline.registeredFunctions = {}
lunr.Pipeline.registeredFunctions = Object.create(null)

@@ -42,0 +42,0 @@ /**

{
"name": "lunr",
"description": "Simple full-text search in your browser.",
"version": "2.0.0",
"version": "2.0.1",
"author": "Oliver Nightingale",

@@ -6,0 +6,0 @@ "keywords": ["search"],

suite('lunr.Builder', function () {
suite('#add', function () {
setup(function () {
this.builder = new lunr.Builder
})
test('field contains terms that clash with object prototype', function () {
this.builder.field('title')
this.builder.add({ id: 'id', title: 'constructor'})
assert.deepProperty(this.builder.invertedIndex, 'constructor.title.id')
assert.deepEqual(this.builder.invertedIndex.constructor.title.id, {})
})
test('field name clashes with object prototype', function () {
this.builder.field('constructor')
this.builder.add({ id: 'id', constructor: 'constructor'})
assert.deepProperty(this.builder.invertedIndex, 'constructor.constructor.id')
assert.deepEqual(this.builder.invertedIndex.constructor.constructor.id, {})
})
test('document ref clashes with object prototype', function () {
this.builder.field('title')
this.builder.add({ id: 'constructor', title: 'word'})
assert.deepProperty(this.builder.invertedIndex, 'word.title.constructor')
assert.deepEqual(this.builder.invertedIndex.word.title.constructor, {})
})
test('token metadata clashes with object prototype', function () {
var pipelineFunction = function (t) {
t.metadata['constructor'] = 'foo'
return t
}
lunr.Pipeline.registerFunction(pipelineFunction, 'test')
this.builder.pipeline.add(pipelineFunction)
// the registeredFunctions object is global, this is to prevent
// polluting any other tests.
delete lunr.Pipeline.registeredFunctions.test
this.builder.metadataWhitelist.push('constructor')
this.builder.field('title')
this.builder.add({ id: 'id', title: 'word'})
assert.deepProperty(this.builder.invertedIndex, 'word.title.id.constructor')
assert.deepEqual(this.builder.invertedIndex.word.title.id.constructor, ['foo'])
})
})
suite('#field', function () {

@@ -3,0 +54,0 @@ test('defining fields to index', function () {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc