diff2html/src/utils.js

43 lines
746 B
JavaScript
Raw Normal View History

2015-04-11 23:09:05 +00:00
/*
*
* Utils (utils.js)
* Author: rtfpessoa
*
*/
(function(ctx, undefined) {
2015-04-11 23:09:05 +00:00
2015-04-12 01:59:54 +00:00
function Utils() {
}
2015-04-11 23:09:05 +00:00
Utils.prototype.escape = function(str) {
2015-04-12 01:59:54 +00:00
return str.slice(0)
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/\t/g, ' ');
2015-04-12 01:59:54 +00:00
};
2015-04-11 23:09:05 +00:00
Utils.prototype.startsWith = function(str, start) {
if (typeof start === 'object') {
var result = false;
start.forEach(function(s) {
if (str.indexOf(s) === 0) {
result = true;
}
});
return result;
}
2015-04-12 01:59:54 +00:00
return str.indexOf(start) === 0;
};
Utils.prototype.valueOrEmpty = function(value) {
return value ? value : '';
2015-04-12 01:59:54 +00:00
};
module.exports['Utils'] = new Utils();
2015-04-12 01:59:54 +00:00
})(this);