trueValue, falseValue of keyIn accept function

This commit is contained in:
anseki 2015-04-20 16:43:12 +09:00
parent 57758fa427
commit e952a7b089

View file

@ -811,16 +811,13 @@ exports.keyIn = function(query, options) {
readOptions.limit = readOptions.limitSrc.join('').replace(/[^A-Za-z0-9_ ]/g, '\\$&');
['trueValue', 'falseValue'].forEach(function(optionName) {
var comps = [];
readOptions[optionName].forEach(function(comp) {
readOptions[optionName] = readOptions[optionName].reduce(function(comps, comp) {
var type = typeof comp;
if (type === 'string' || type === 'number') {
comps = comps.concat((comp + '').split(''));
} else if (comp instanceof RegExp) {
comps.push(comp);
}
});
readOptions[optionName] = comps;
} else { comps.push(comp); }
return comps;
}, []);
});
readOptions.display = replacePlaceholder(readOptions.display + '',