Socket
Socket
Sign inDemoInstall

lunr

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lunr - npm Package Compare versions

Comparing version 2.0.0-alpha.2 to 2.0.0-alpha.3

2

.eslintrc.json

@@ -27,3 +27,3 @@ {

"whitespace", "automata", "i", "obj", "anymore", "lexer", "var", "refs",
"serializable", "tis", "twas", "int"
"serializable", "tis", "twas", "int", "args", "unshift", "plugins"
]

@@ -30,0 +30,0 @@ }

@@ -269,1 +269,21 @@ /*!

}
/**
* Applies a plugin to the index builder.
*
* A plugin is a function that is called with the index builder as its context.
* Plugins can be used to customise or extend the behaviour of the index
* in some way. A plugin is just a function, that encapsulated the custom
* behaviour that should be applied when building the index.
*
* The plugin function will be called with the index builder as its argument, additional
* arguments can also be passed when calling use. The function will be called
* with the index builder as its context.
*
* @param {Function} plugin The plugin to apply.
*/
lunr.Builder.prototype.use = function (fn) {
var args = Array.prototype.slice.call(arguments, 1)
args.unshift(this)
fn.apply(this, args)
}
{
"name": "lunr",
"description": "Simple full-text search in your browser.",
"version": "2.0.0-alpha.2",
"version": "2.0.0-alpha.3",
"author": "Oliver Nightingale",

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

@@ -61,2 +61,40 @@ suite('lunr.Builder', function () {

suite('#use', function () {
setup(function () {
this.builder = new lunr.Builder
})
test('calls plugin function', function () {
var wasCalled = false,
plugin = function () { wasCalled = true }
this.builder.use(plugin)
assert.isTrue(wasCalled)
})
test('sets context to the builder instance', function () {
var context = null,
plugin = function () { context = this }
this.builder.use(plugin)
assert.equal(context, this.builder)
})
test('passes builder as first argument', function () {
var arg = null,
plugin = function (a) { arg = a }
this.builder.use(plugin)
assert.equal(arg, this.builder)
})
test('forwards arguments to the plugin', function () {
var args = null,
plugin = function () { args = [].slice.call(arguments) }
this.builder.use(plugin, 1, 2, 3)
assert.deepEqual(args, [this.builder, 1, 2, 3])
})
})
suite('#build', function () {

@@ -63,0 +101,0 @@ setup(function () {

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc