Skip to content

Commit

Permalink
Released 0.4.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianreavis committed Jan 28, 2015
1 parent e79a54d commit 2bd21aa
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sifter",
"keywords": ["search","filter","sift","data","results","match","sort","autocomplete"],
"description": "A library for textually searching arrays and hashes of objects by property (or multiple properties). Designed specifically for autocomplete.",
"version": "0.3.4",
"version": "0.4.0",
"license": "Apache License, Version 2.0",
"readmeFilename": "README.md",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"autocomplete"
],
"description": "A library for textually searching arrays and hashes of objects by property (or multiple properties). Designed specifically for autocomplete.",
"version": "0.3.4",
"version": "0.4.0",
"author": "Brian Reavis <brian@thirdroute.com>",
"main": "./sifter.js",
"repository": {
Expand Down
39 changes: 31 additions & 8 deletions sifter.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
* @param {object} result
* @return {mixed}
*/
get_field = function(name, result) {
get_field = function(name, result) {
if (name === '$score') return result.score;
return self.items[result.id][name];
};
Expand Down Expand Up @@ -391,8 +391,8 @@
if (typeof a === 'number' && typeof b === 'number') {
return a > b ? 1 : (a < b ? -1 : 0);
}
a = String(a || '').toLowerCase();
b = String(b || '').toLowerCase();
a = asciifold(String(a || ''));
b = asciifold(String(b || ''));
if (a > b) return 1;
if (b > a) return -1;
return 0;
Expand Down Expand Up @@ -425,21 +425,44 @@
};

var DIACRITICS = {
'a': '[aÀÁÂÃÄÅàáâãäåĀā]',
'a': '[aÀÁÂÃÄÅàáâãäåĀāąĄ]',
'c': '[cÇçćĆčČ]',
'd': '[dđĐďĎ]',
'e': '[eÈÉÊËèéêëěĚĒē]',
'e': '[eÈÉÊËèéêëěĚĒēęĘ]',
'i': '[iÌÍÎÏìíîïĪī]',
'n': '[nÑñňŇ]',
'l': '[lłŁ]',
'n': '[nÑñňŇńŃ]',
'o': '[oÒÓÔÕÕÖØòóôõöøŌō]',
'r': '[rřŘ]',
's': '[sŠš]',
's': '[sŠšśŚ]',
't': '[tťŤ]',
'u': '[uÙÚÛÜùúûüůŮŪū]',
'y': '[yŸÿýÝ]',
'z': '[zŽž]'
'z': '[zŽžżŻźŹ]'
};

var asciifold = (function() {
var i, n, k, chunk;
var foreignletters = '';
var lookup = {};
for (k in DIACRITICS) {
if (DIACRITICS.hasOwnProperty(k)) {
chunk = DIACRITICS[k].substring(2, DIACRITICS[k].length - 1);
foreignletters += chunk;
for (i = 0, n = chunk.length; i < n; i++) {
lookup[chunk.charAt(i)] = k;
}
}
}
var regexp = new RegExp('[' + foreignletters + ']', 'g');
return function(str) {
return str.replace(regexp, function(foreignletter) {
return lookup[foreignletter];
}).toLowerCase();
};
})();


// export
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Expand Down
2 changes: 1 addition & 1 deletion sifter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2bd21aa

Please sign in to comment.