updated modelbinder, mutator, pagable, lunr.

This commit is contained in:
kay.one 2013-05-20 14:10:21 -07:00
commit 8528bb1301
4 changed files with 132 additions and 89 deletions

View file

@ -1,5 +1,5 @@
/**
* lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 0.3.1
* lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 0.3.2
* Copyright (C) 2013 Oliver Nightingale
* MIT Licensed
* @license
@ -50,7 +50,7 @@ var lunr = function (config) {
return idx
}
lunr.version = "0.3.1"
lunr.version = "0.3.2"
if (typeof module !== 'undefined') {
module.exports = lunr
@ -69,6 +69,7 @@ if (typeof module !== 'undefined') {
* @returns {Array}
*/
lunr.tokenizer = function (str) {
if (!str) return []
if (Array.isArray(str)) return str
var str = str.replace(/^\s+/, '')
@ -737,8 +738,11 @@ lunr.Index.prototype.add = function (doc) {
for (var i = 0; i < allDocumentTokens.length; i++) {
var token = allDocumentTokens.elements[i]
var tf = this._fields.reduce(function (memo, field) {
var tokenCount = docTokens[field.name].filter(function (t) { return t === token }).length,
fieldLength = docTokens[field.name].length
var fieldLength = docTokens[field.name].length
if (!fieldLength) return memo
var tokenCount = docTokens[field.name].filter(function (t) { return t === token }).length
return memo + (tokenCount / fieldLength * field.boost)
}, 0)