esmile-useful
Advanced tools
Comparing version 0.0.25-dev.0.0.1 to 0.0.26
34
index.js
/* It's exporting all the functions in the file. */ | ||
exports.isValidNumber = require("./src/validation/isValidNumber") | ||
exports.isEmptyString = require("./src/validation/isEmptyString") | ||
exports.isValidUrl = require("./src/validation/isValidUrl") | ||
exports.isValidEmail = require("./src/validation/isValidEmail") | ||
exports.isValidNumber = require("./src/validation/isValidNumber"); | ||
exports.isEmptyString = require("./src/validation/isEmptyString"); | ||
exports.isValidUrl = require("./src/validation/isValidUrl"); | ||
exports.isValidEmail = require("./src/validation/isValidEmail"); | ||
exports.generateCaptcha = require("./src/gen/generateCaptcha") | ||
exports.generateKey = require("./src/gen/generateKey") | ||
exports.generateCaptcha = require("./src/gen/generateCaptcha"); | ||
exports.generateKey = require("./src/gen/generateKey"); | ||
exports.colorHashtag = require("./src/color/colorHashtag") | ||
exports.colorZero = require("./src/color/colorZero") | ||
exports.listLogColor = require("./src/color/listLogColor") | ||
exports.colorHashtag = require("./src/color/colorHashtag"); | ||
exports.colorZero = require("./src/color/colorZero"); | ||
exports.listLogColor = require("./src/color/listLogColor"); | ||
exports.millisecond = require("./src/utils/millisecond") | ||
exports.wait = require("./src/utils/wait") | ||
exports.log = require("./src/utils/log") | ||
exports.type = require("./src/utils/type") | ||
exports.random = require("./src/utils/random") | ||
exports.randomItem = require("./src/utils/randomItem") | ||
exports.symbols = require("./src/utils/symbols") | ||
exports.millisecond = require("./src/utils/millisecond"); | ||
exports.wait = require("./src/utils/wait"); | ||
exports.log = require("./src/utils/log"); | ||
exports.type = require("./src/utils/type"); | ||
exports.random = require("./src/utils/random"); | ||
exports.randomItem = require("./src/utils/randomItem"); | ||
exports.symbols = require("./src/utils/symbols"); | ||
exports.version = require("./package.json").version | ||
exports.version = require("./package.json").version; |
{ | ||
"name": "esmile-useful", | ||
"version": "0.0.25-dev.0.0.1", | ||
"version": "0.0.26", | ||
"description": "Esmile Utility", | ||
@@ -23,2 +23,3 @@ "main": "index.js", | ||
"license": "Copyright", | ||
"types": "index.d.ts", | ||
"engines": { | ||
@@ -25,0 +26,0 @@ "node": ">=16.9.0" |
@@ -0,0 +0,0 @@ ## Installation |
@@ -306,3 +306,2 @@ /** | ||
DarkImperialBlue: "#00416A", | ||
DarkImperialBlue: "#00147E", | ||
DarkJungleGreen: "#1A2421", | ||
@@ -758,3 +757,2 @@ DarkKhaki: "#BDB76B", | ||
MiddleRed: "#E58E73", | ||
MiddleRedPurple: "#A55353", | ||
MiddleYellow: "#FFEB00", | ||
@@ -895,3 +893,2 @@ MiddleYellowRed: "#ECB176", | ||
Peach: "#FFE5B4", | ||
Peach: "#FFCBA4", | ||
Peach_Orange: "#FFCC99", | ||
@@ -1033,3 +1030,2 @@ PeachPuff: "#FFDAB9", | ||
RoyalBlue: "#002366", | ||
RoyalBlue: "#4169E1", | ||
RoyalFuchsia: "#CA2C92", | ||
@@ -1074,3 +1070,2 @@ RoyalPurple: "#7851A9", | ||
Scarlet: "#FF2400", | ||
Scarlet: "#FD0E35", | ||
SchaussPink: "#FF91AF", | ||
@@ -1169,3 +1164,2 @@ SchoolBusYellow: "#FFD800", | ||
TeaRose: "#F88379", | ||
TeaRose: "#F4C2C2", | ||
Teal: "#008080", | ||
@@ -1240,3 +1234,2 @@ TealBlue: "#367588", | ||
Vermilion: "#E34234", | ||
Vermilion: "#D9381E", | ||
Veronica: "#A020F0", | ||
@@ -1319,2 +1312,2 @@ VeryLightAzure: "#74BBFB", | ||
Zomp: "#39A78E", | ||
} | ||
}; |
@@ -306,3 +306,2 @@ /** | ||
DarkImperialBlue: "0x00416A", | ||
DarkImperialBlue: "0x00147E", | ||
DarkJungleGreen: "0x1A2421", | ||
@@ -758,3 +757,2 @@ DarkKhaki: "0xBDB76B", | ||
MiddleRed: "0xE58E73", | ||
MiddleRedPurple: "0xA55353", | ||
MiddleYellow: "0xFFEB00", | ||
@@ -895,3 +893,2 @@ MiddleYellowRed: "0xECB176", | ||
Peach: "0xFFE5B4", | ||
Peach: "0xFFCBA4", | ||
Peach_Orange: "0xFFCC99", | ||
@@ -1033,3 +1030,2 @@ PeachPuff: "0xFFDAB9", | ||
RoyalBlue: "0x002366", | ||
RoyalBlue: "0x4169E1", | ||
RoyalFuchsia: "0xCA2C92", | ||
@@ -1074,3 +1070,2 @@ RoyalPurple: "0x7851A9", | ||
Scarlet: "0xFF2400", | ||
Scarlet: "0xFD0E35", | ||
SchaussPink: "0xFF91AF", | ||
@@ -1169,3 +1164,2 @@ SchoolBusYellow: "0xFFD800", | ||
TeaRose: "0xF88379", | ||
TeaRose: "0xF4C2C2", | ||
Teal: "0x008080", | ||
@@ -1240,3 +1234,2 @@ TealBlue: "0x367588", | ||
Vermilion: "0xE34234", | ||
Vermilion: "0xD9381E", | ||
Veronica: "0xA020F0", | ||
@@ -1319,2 +1312,2 @@ VeryLightAzure: "0x74BBFB", | ||
Zomp: "0x39A78E", | ||
} | ||
}; |
@@ -33,2 +33,2 @@ /** | ||
BgWhite: "\x1b[47m%s\x1b[0m", | ||
} | ||
}; |
@@ -12,9 +12,9 @@ /** | ||
alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""), | ||
captchaLength = captchaLength || 5 | ||
captchaLength = captchaLength || 5; | ||
for (var i = 0; i < captchaLength; i++) { | ||
captcha = captcha + alphabets[Math.ceil(Math.random() * 25)] | ||
captcha = captcha + alphabets[Math.ceil(Math.random() * 25)]; | ||
} | ||
return captcha | ||
return captcha; | ||
} | ||
module.exports = generateCaptcha | ||
module.exports = generateCaptcha; |
@@ -11,9 +11,9 @@ /** | ||
if (!prefix) { | ||
const key = "0x" + "PREFIX" + "x" + Date.now() | ||
return key | ||
const key = "0x" + "PREFIX" + "x" + Date.now(); | ||
return key; | ||
} | ||
const key = "0x" + prefix + "x" + Date.now() | ||
return key | ||
const key = "0x" + prefix + "x" + Date.now(); | ||
return key; | ||
} | ||
module.exports = generateKey | ||
module.exports = generateKey; |
@@ -14,8 +14,8 @@ /** | ||
if (color) { | ||
return console.log(color, text) | ||
return console.log(color, text); | ||
} else { | ||
return console.log(text) | ||
return console.log(text); | ||
} | ||
} | ||
module.exports = log | ||
module.exports = log; |
@@ -19,7 +19,7 @@ /** | ||
amount, | ||
match | ||
match; | ||
if ("number" === type) return ms | ||
if ("string" !== type) return 0 | ||
if (!isNaN(+ms)) return +ms | ||
if ("number" === type) return ms; | ||
if ("string" !== type) return 0; | ||
if (!isNaN(+ms)) return +ms; | ||
@@ -52,7 +52,7 @@ var regex = new RegExp( | ||
"i" | ||
) | ||
); | ||
if (ms.length > 10000 || !(match = regex.exec(ms))) return 0 | ||
if (ms.length > 10000 || !(match = regex.exec(ms))) return 0; | ||
amount = parseFloat(match[1]) | ||
amount = parseFloat(match[1]); | ||
@@ -64,3 +64,3 @@ var second = 1000, | ||
week = day * 7, | ||
year = day * 365 | ||
year = day * 365; | ||
@@ -73,3 +73,3 @@ switch (match[2].toLowerCase()) { | ||
case "y": | ||
return amount * year | ||
return amount * year; | ||
@@ -81,3 +81,3 @@ case "weeks": | ||
case "w": | ||
return amount * week | ||
return amount * week; | ||
@@ -87,3 +87,3 @@ case "days": | ||
case "d": | ||
return amount * day | ||
return amount * day; | ||
@@ -95,3 +95,3 @@ case "hours": | ||
case "h": | ||
return amount * hour | ||
return amount * hour; | ||
@@ -103,3 +103,3 @@ case "minutes": | ||
case "m": | ||
return amount * minute | ||
return amount * minute; | ||
@@ -111,9 +111,9 @@ case "seconds": | ||
case "s": | ||
return amount * second | ||
return amount * second; | ||
default: | ||
return amount | ||
return amount; | ||
} | ||
} | ||
module.exports = millisecond | ||
module.exports = millisecond; |
@@ -12,7 +12,7 @@ /** | ||
function random(min, max) { | ||
if (!max) return min | ||
const r = Math.random() * (max - min) + min | ||
return Math.floor(r) | ||
if (!max) return min; | ||
const r = Math.random() * (max - min) + min; | ||
return Math.floor(r); | ||
} | ||
module.exports = random | ||
module.exports = random; |
@@ -11,5 +11,5 @@ /** | ||
function randomItem(items) { | ||
return items[Math.floor(Math.random() * items.length)] | ||
return items[Math.floor(Math.random() * items.length)]; | ||
} | ||
module.exports = randomItem | ||
module.exports = randomItem; |
@@ -237,2 +237,2 @@ /** | ||
oneTenth: "⅒", | ||
} | ||
}; |
@@ -15,7 +15,7 @@ /** | ||
function type(obj) { | ||
var undef | ||
if (obj === undef) return "undefined" | ||
if (obj === null) return "null" | ||
var undef; | ||
if (obj === undef) return "undefined"; | ||
if (obj === null) return "null"; | ||
var t = typeof obj | ||
var t = typeof obj; | ||
@@ -27,32 +27,32 @@ switch (t) { | ||
case "function": | ||
return t | ||
return t; | ||
} | ||
var toString = Object.prototype.toString | ||
var toString = Object.prototype.toString; | ||
var str = toString.call(obj) | ||
var str = toString.call(obj); | ||
switch (str) { | ||
case "[object Array]": | ||
return "array" | ||
return "array"; | ||
case "[object RegExp]": | ||
return "regexp" | ||
return "regexp"; | ||
case "[object Date]": | ||
return "date" | ||
return "date"; | ||
case "[object Arguments]": | ||
return "arguments" | ||
return "arguments"; | ||
case "[object Function]": | ||
return "function" | ||
return "function"; | ||
case "[object Boolean]": | ||
return "boolean" | ||
return "boolean"; | ||
case "[object Number]": | ||
return "number" | ||
return "number"; | ||
case "[object String]": | ||
return "string" | ||
return "string"; | ||
default: | ||
if (isBuffer(obj)) return "buffer" | ||
return "object" | ||
if (isBuffer(obj)) return "buffer"; | ||
return "object"; | ||
} | ||
} | ||
module.exports = type | ||
module.exports = type; |
@@ -14,2 +14,2 @@ /** | ||
module.exports = (delay = 0) => new Promise((resolve) => setTimeout(resolve, delay)) | ||
module.exports = (delay = 0) => new Promise((resolve) => setTimeout(resolve, delay)); |
@@ -11,5 +11,5 @@ /** | ||
function isEmptyString(value) { | ||
return value === "" | ||
return value === ""; | ||
} | ||
module.exports = isEmptyString | ||
module.exports = isEmptyString; |
@@ -11,22 +11,21 @@ /** | ||
function isValidEmail(email) { | ||
if (!email) return false | ||
var emailParts = email.split("@") | ||
if (emailParts.length !== 2) return false | ||
var account = emailParts[0] | ||
var address = emailParts[1] | ||
if (account.length > 64) return false | ||
else if (address.length > 255) return false | ||
var domainParts = address.split(".") | ||
if (!email) return false; | ||
var emailParts = email.split("@"); | ||
if (emailParts.length !== 2) return false; | ||
var account = emailParts[0]; | ||
var address = emailParts[1]; | ||
if (account.length > 64) return false; | ||
else if (address.length > 255) return false; | ||
var domainParts = address.split("."); | ||
if ( | ||
domainParts.some(function (part) { | ||
return part.length > 63 | ||
return part.length > 63; | ||
}) | ||
) | ||
return false | ||
var tester = | ||
/^[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/ | ||
if (!tester.test(email)) return false | ||
return true | ||
return false; | ||
var tester = /^[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/; | ||
if (!tester.test(email)) return false; | ||
return true; | ||
} | ||
module.exports = isValidEmail | ||
module.exports = isValidEmail; |
@@ -11,5 +11,5 @@ /** | ||
function isValidNumber(number) { | ||
return /^[0-9]+$/.test(number) | ||
return /^[0-9]+$/.test(number); | ||
} | ||
module.exports = isValidNumber | ||
module.exports = isValidNumber; |
@@ -13,10 +13,10 @@ /** | ||
let regex = | ||
/(?:(?:https?|ftp|file|http?):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/gim | ||
const match = regex.test(content) | ||
let urls = content.match(regex) | ||
urls = urls.filter((url) => !whitelist.find((wurl) => url.includes(wurl))) | ||
if (urls.length === 0) return false | ||
return match | ||
/(?:(?:https?|ftp|file|http?):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/gim; | ||
const match = regex.test(content); | ||
let urls = content.match(regex); | ||
urls = urls.filter((url) => !whitelist.find((wurl) => url.includes(wurl))); | ||
if (urls.length === 0) return false; | ||
return match; | ||
} | ||
module.exports = isValidUrl | ||
module.exports = isValidUrl; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
156083
20
6064