Add narrow.describe

(imported from commit df123384754701108fe7597710cb0cf46cb86caf)
This commit is contained in:
Keegan McAllister 2012-12-17 18:18:30 -05:00
parent 6d50e233ec
commit d2705ab913

View File

@ -58,6 +58,32 @@ function unparse(operators) {
return parts.join(' ');
}
// Convert a list of operators to a human-readable description.
exports.describe = function (operators) {
return $.map(operators, function (elem) {
var operand = elem[1];
switch (elem[0]) {
case 'is':
if (operand === 'private-message')
return 'private messages';
break;
case 'stream':
return 'stream ' + operand;
case 'subject':
return 'subject ' + operand;
case 'pm-with':
return 'private messages with ' + operand;
case 'search':
return 'messages containing ' + operand;
}
return '(unknown operator)';
}).join(', ');
};
// Parse a string into a list of operators (see below).
exports.parse = function (str) {
var operators = [];