Conversion to TS
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
96f22efb58
commit
81a859a8d9
@ -1,8 +1,8 @@
|
|||||||
const htmlShrink = require('html-minifier').minify;
|
const htmlShrink = require('html-minifier').minify;
|
||||||
const juice = require('juice');
|
const juice = require('juice');
|
||||||
|
|
||||||
module.exports = async function minifyMail(input) {
|
module.exports = async function minifyMail(input: string): Promise<string> {
|
||||||
const inlined = juice(input);
|
const inlined: string = juice(input);
|
||||||
return htmlShrink(inlined, {
|
return htmlShrink(inlined, {
|
||||||
removeComments: true,
|
removeComments: true,
|
||||||
collapseWhitespace: true
|
collapseWhitespace: true
|
@ -1,26 +1,26 @@
|
|||||||
//const log = require('../utils/log.utils');
|
//const log = require('../utils/log.utils');
|
||||||
|
|
||||||
function removeNonAlphanumeric(inputString) {
|
function removeNonAlphanumeric(inputString: string) {
|
||||||
return inputString.replace(/[^a-zA-Z0-9]/g, '');
|
return inputString.replace(/[^a-zA-Z0-9]/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeNonAlpha(inputString) {
|
function removeNonAlpha(inputString: string) {
|
||||||
return inputString.replace(/[^a-zA-Z]/g, '');
|
return inputString.replace(/[^a-zA-Z]/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeNonNumeric(inputString) {
|
function removeNonNumeric(inputString: string) {
|
||||||
return inputString.replace(/[^0-9]/g, '');
|
return inputString.replace(/[^0-9]/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
const cleanApiEndpointTxt = removeNonAlpha;
|
const cleanApiEndpointTxt = removeNonAlpha;
|
||||||
const cleanApiEndpointNum = removeNonAlphanumeric;
|
const cleanApiEndpointNum = removeNonAlphanumeric;
|
||||||
|
|
||||||
function cleanNrcc(input) { // Remove newlines and then <p> tags from input
|
function cleanNrcc(input: string) { // Remove newlines and then <p> tags from input
|
||||||
const cleanInput = input.replace(/[\n\r]/g, '').replace(/<\/?p[^>]*>/g, '');
|
const cleanInput = input.replace(/[\n\r]/g, '').replace(/<\/?p[^>]*>/g, '');
|
||||||
return cleanInput;
|
return cleanInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getDomainFromEmail(mail) { // Needs testing
|
async function getDomainFromEmail(mail: string) { // Needs testing
|
||||||
let split = mail.split('@');
|
let split = mail.split('@');
|
||||||
return split[1];
|
return split[1];
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
function unixLocal(unix) {
|
function unixLocal(unix: number) {
|
||||||
var jsTime = unix*1000;
|
var jsTime = unix*1000;
|
||||||
var dt = new Date(jsTime);
|
var dt = new Date(jsTime);
|
||||||
return dt.toLocaleString();
|
return dt.toLocaleString();
|
||||||
}
|
}
|
||||||
|
|
||||||
function jsUnix(js) {
|
function jsUnix(js: number) {
|
||||||
var preRound = js / 1000;
|
var preRound = js / 1000;
|
||||||
return Math.round(preRound);
|
return Math.round(preRound);
|
||||||
}
|
}
|
@ -55,7 +55,7 @@
|
|||||||
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||||
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
||||||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
||||||
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
||||||
// "removeComments": true, /* Disable emitting comments. */
|
// "removeComments": true, /* Disable emitting comments. */
|
||||||
// "noEmit": true, /* Disable emitting files from a compilation. */
|
// "noEmit": true, /* Disable emitting files from a compilation. */
|
||||||
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||||
|
Loading…
Reference in New Issue
Block a user