UNPKG

@szegedsw/lib-node

Version:

A little framework published by Szeged Software Zrt. in order to enhance api endpoint security and create reuseable code. Email module, Logging system, and much more. Further improvements are expected.

27 lines 1.08 kB
"use strict"; // eslint-disable-next-line func-names String.prototype.encodeToBase64 = function () { return Buffer.from(this.toString()).toString("base64"); }; // eslint-disable-next-line func-names String.prototype.decodeFromBase64 = function () { return Buffer.from(this.toString(), "base64").toString(); }; // eslint-disable-next-line func-names String.prototype.toRegexFilter = function () { // eslint-disable-next-line no-nested-ternary return Array.from(this || []).some((char) => ["?", "*"].includes(char)) ? { $regex: `^${(this || "").split("?").join(".").split("*").join(".*")}$` } : (this || "").trim().length > 0 ? this.toString() : undefined; }; /** * @description Y, TRUE, 1 -> true, * @description N, FALSE, 0, UNDEFINED -> false */ // eslint-disable-next-line func-names String.prototype.toBoolean = function () { return (["Y", "TRUE", "1"].includes(this.toUpperCase()) || (!["N", "FALSE", "0", "UNDEFINED"].includes(this.toUpperCase()) && Boolean(this))); }; //# sourceMappingURL=string.ext.js.map