/* * * Utils (utils.js) * Author: rtfpessoa * */ (function() { var merge = require('merge'); function Utils() { } Utils.prototype.escape = function(str) { return str.slice(0) .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, ''') .replace(/\//g, '/'); }; 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; } return str && str.indexOf(start) === 0; }; Utils.prototype.valueOrEmpty = function(value) { return value || ''; }; Utils.prototype.safeConfig = function(cfg, defaultConfig) { return merge.recursive(true, defaultConfig, cfg); }; module.exports.Utils = new Utils(); })();