This commit is contained in:
Benjamin Toby
2024-11-18 18:14:15 +01:00
parent 5d9f95f37e
commit aafd76b507
6 changed files with 59 additions and 8 deletions
+24
View File
@@ -0,0 +1,24 @@
export = trimSql;
/**
* @typedef {object} GrabHostNamesReturn
* @property {string} host
* @property {number | string} port
* @property {typeof http | typeof https} scheme
*/
/**
* # Trim SQL
* @description Remove Returns and miltiple spaces from SQL Query
* @param {string} sql
* @returns {string}
*/
declare function trimSql(sql: string): string;
declare namespace trimSql {
export { GrabHostNamesReturn };
}
type GrabHostNamesReturn = {
host: string;
port: number | string;
scheme: typeof http | typeof https;
};
import http = require("http");
import https = require("https");
+26
View File
@@ -0,0 +1,26 @@
// @ts-check
const https = require("https");
const http = require("http");
/**
* @typedef {object} GrabHostNamesReturn
* @property {string} host
* @property {number | string} port
* @property {typeof http | typeof https} scheme
*/
/**
* # Trim SQL
* @description Remove Returns and miltiple spaces from SQL Query
* @param {string} sql
* @returns {string}
*/
function trimSql(sql) {
return sql
.replace(/\n|\r|\n\r|\r\n/gm, " ")
.replace(/ {2,}/g, " ")
.trim();
}
module.exports = trimSql;