jed/locale — pull request #17 by stuartf (2014-01-22 16:58:53+00:00)
Title: Npm version (0.0.12) - best not working properly

The code has a problem, you return the last matching element, not the first.
The version in the git repo seems to differ

Locales.prototype.best = function(locales) {
var index, item, locale, _i, _len;

locale = Locale["default"];
if (!locales) {
return this[0] || locale;
}
index = locales.index();
for (_i = 0, _len = this.length; _i < _len; _i++) {
item = this[_i];
if (index[item]) {
return item;
} else {
if (index[item.language]) {
locale = new Locale(item.language);
}
}
}
return locale;
};

vs

best: (locales) ->
locale = Locale.default

unless locales
return @[0] or locale

index = do locales.index

for item in @
if index[item]
return item
else if index[item.language] then locale = new Locale item.language
else
for l in locales
if l.language == item.language then return l

locale