|
|
|
@ -2,9 +2,7 @@
|
|
|
|
|
|
|
|
|
|
(function (factory) {
|
|
|
|
|
if (typeof module === 'object' && module.exports) {
|
|
|
|
|
const winston = require('winston');
|
|
|
|
|
|
|
|
|
|
module.exports = factory(require('xregexp'), winston);
|
|
|
|
|
module.exports = factory();
|
|
|
|
|
|
|
|
|
|
process.profile = function (operation, start) {
|
|
|
|
|
console.log('%s took %d milliseconds', operation, process.elapsedTimeSince(start));
|
|
|
|
@ -15,14 +13,12 @@
|
|
|
|
|
return (diff[0] * 1e3) + (diff[1] / 1e6);
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
window.utils = factory(window.XRegExp, console);
|
|
|
|
|
window.utils = factory();
|
|
|
|
|
}
|
|
|
|
|
// eslint-disable-next-line
|
|
|
|
|
}(function (XRegExp, console) {
|
|
|
|
|
const freeze = Object.freeze || function (obj) { return obj; };
|
|
|
|
|
|
|
|
|
|
}(function () {
|
|
|
|
|
// add default escape function for escaping HTML entities
|
|
|
|
|
const escapeCharMap = freeze({
|
|
|
|
|
const escapeCharMap = Object.freeze({
|
|
|
|
|
'&': '&',
|
|
|
|
|
'<': '<',
|
|
|
|
|
'>': '>',
|
|
|
|
@ -36,7 +32,7 @@
|
|
|
|
|
}
|
|
|
|
|
const escapeChars = /[&<>"'`=]/g;
|
|
|
|
|
|
|
|
|
|
const HTMLEntities = freeze({
|
|
|
|
|
const HTMLEntities = Object.freeze({
|
|
|
|
|
amp: '&',
|
|
|
|
|
gt: '>',
|
|
|
|
|
lt: '<',
|
|
|
|
@ -373,13 +369,13 @@
|
|
|
|
|
return utils.languageKeyRegex.test(input);
|
|
|
|
|
},
|
|
|
|
|
userLangToTimeagoCode: function (userLang) {
|
|
|
|
|
const mapping = {
|
|
|
|
|
const mapping = Object.create(null, {
|
|
|
|
|
'en-GB': 'en',
|
|
|
|
|
'en-US': 'en',
|
|
|
|
|
'fa-IR': 'fa',
|
|
|
|
|
'pt-BR': 'pt-br',
|
|
|
|
|
nb: 'no',
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
return mapping[userLang] || userLang;
|
|
|
|
|
},
|
|
|
|
|
// shallow objects merge
|
|
|
|
@ -401,7 +397,7 @@
|
|
|
|
|
return ('' + path).split('.').pop();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
extensionMimeTypeMap: {
|
|
|
|
|
extensionMimeTypeMap: Object.create(null, {
|
|
|
|
|
bmp: 'image/bmp',
|
|
|
|
|
cmx: 'image/x-cmx',
|
|
|
|
|
cod: 'image/cis-cod',
|
|
|
|
@ -425,7 +421,7 @@
|
|
|
|
|
xbm: 'image/x-xbitmap',
|
|
|
|
|
xpm: 'image/x-xpixmap',
|
|
|
|
|
xwd: 'image/x-xwindowdump',
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
fileMimeType: function (path) {
|
|
|
|
|
return utils.extensionToMimeType(utils.fileExtension(path));
|
|
|
|
|