Conversion to TS

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-07-24 01:04:55 +01:00
parent 96f22efb58
commit 81a859a8d9
5 changed files with 10 additions and 10 deletions

View File

View File

@ -1,8 +1,8 @@
const htmlShrink = require('html-minifier').minify;
const juice = require('juice');
module.exports = async function minifyMail(input) {
const inlined = juice(input);
module.exports = async function minifyMail(input: string): Promise<string> {
const inlined: string = juice(input);
return htmlShrink(inlined, {
removeComments: true,
collapseWhitespace: true

View File

@ -1,26 +1,26 @@
//const log = require('../utils/log.utils');
function removeNonAlphanumeric(inputString) {
function removeNonAlphanumeric(inputString: string) {
return inputString.replace(/[^a-zA-Z0-9]/g, '');
}
function removeNonAlpha(inputString) {
function removeNonAlpha(inputString: string) {
return inputString.replace(/[^a-zA-Z]/g, '');
}
function removeNonNumeric(inputString) {
function removeNonNumeric(inputString: string) {
return inputString.replace(/[^0-9]/g, '');
}
const cleanApiEndpointTxt = removeNonAlpha;
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, '');
return cleanInput;
}
async function getDomainFromEmail(mail) { // Needs testing
async function getDomainFromEmail(mail: string) { // Needs testing
let split = mail.split('@');
return split[1];
}

View File

@ -1,10 +1,10 @@
function unixLocal(unix) {
function unixLocal(unix: number) {
var jsTime = unix*1000;
var dt = new Date(jsTime);
return dt.toLocaleString();
}
function jsUnix(js) {
function jsUnix(js: number) {
var preRound = js / 1000;
return Math.round(preRound);
}

View File

@ -55,7 +55,7 @@
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "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. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
"outDir": "./dist", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "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. */