diff2html/src/utils.js
Rodrigo Fernandes 6514ac7477 clean project, better module exposing and documentation
* use native JS in example instead of jQuery
 * better module exposing now using exports, module.export, self, window, global and this
 * add example link to bower and npm definition
 * add documentation on how to highlight
2015-07-19 22:08:17 +01:00

37 lines
819 B
JavaScript

/*
*
* Utils (utils.js)
* Author: rtfpessoa
*
*/
(function (ctx, undefined) {
function Utils() {
}
Utils.prototype.escape = function (str) {
return str.slice(0)
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/\t/g, " ");
};
Utils.prototype.startsWith = function (str, start) {
return str.indexOf(start) === 0;
};
Utils.prototype.valueOrEmpty = function (value) {
return value ? value : "";
};
// expose this module
((typeof module !== 'undefined' && module.exports) ||
(typeof exports !== 'undefined' && exports) ||
(typeof window !== 'undefined' && window) ||
(typeof self !== 'undefined' && self) ||
(typeof $this !== 'undefined' && $this) ||
Function('return this')())["Utils"] = new Utils();
})(this);