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, '\\$&'); readOptions.limit = readOptions.limitSrc.join('').replace(/[^A-Za-z0-9_ ]/g, '\\$&');
['trueValue', 'falseValue'].forEach(function(optionName) { ['trueValue', 'falseValue'].forEach(function(optionName) {
var comps = []; readOptions[optionName] = readOptions[optionName].reduce(function(comps, comp) {
readOptions[optionName].forEach(function(comp) {
var type = typeof comp; var type = typeof comp;
if (type === 'string' || type === 'number') { if (type === 'string' || type === 'number') {
comps = comps.concat((comp + '').split('')); comps = comps.concat((comp + '').split(''));
} else if (comp instanceof RegExp) { } else { comps.push(comp); }
comps.push(comp); return comps;
} }, []);
});
readOptions[optionName] = comps;
}); });
readOptions.display = replacePlaceholder(readOptions.display + '', readOptions.display = replacePlaceholder(readOptions.display + '',