almost can do tests

This commit is contained in:
Peter Cottle 2012-12-17 11:26:50 -08:00
parent 565142048c
commit ddf399e099
10 changed files with 288 additions and 163 deletions

View file

@ -1,5 +1,24 @@
var _ = require('underscore');
exports.isBrowser = function() {
var inBrowser = String(typeof window) !== 'undefined';
return inBrowser;
};
exports.splitTextCommand = function(value, func, context) {
func = _.bind(func, context);
_.each(value.split(';'), function(command, index) {
command = _.escape(command);
command = command
.replace(/^(\s+)/, '')
.replace(/(\s+)$/, '')
.replace(/"/g, '"')
.replace(/'/g, "'");
if (index > 0 && !command.length) {
return;
}
func(command);
});
};