esmile-useful
Advanced tools
Comparing version 0.0.23-dev.0.0.1 to 0.0.23
/* It's exporting all the functions in the file. */ | ||
exports.kiss = require("./src/img/interaction/kiss") | ||
exports.pat = require("./src/img/interaction/pat") | ||
exports.hug = require("./src/img/interaction/hug") | ||
exports.feed = require("./src/img/interaction/feed") | ||
exports.slap = require("./src/img/interaction/slap") | ||
exports.isValidNumber = require("./src/validation/isValidNumber") | ||
@@ -9,0 +3,0 @@ exports.isEmptyString = require("./src/validation/isEmptyString") |
{ | ||
"name": "esmile-useful", | ||
"version": "0.0.23-dev.0.0.1", | ||
"version": "0.0.23", | ||
"description": "Esmile Utility", | ||
@@ -23,5 +23,2 @@ "main": "index.js", | ||
"license": "Copyright", | ||
"dependencies": { | ||
"node-fetch": "^3.2.10" | ||
}, | ||
"engines": { | ||
@@ -28,0 +25,0 @@ "node": ">=16.9.0" |
@@ -24,12 +24,2 @@ ## Installation | ||
### Images | ||
| Function | Description | | ||
| -------- | ------------------------------ | | ||
| `kiss` | Gets a URL of a kiss image/gif | | ||
| `pat` | Gets a URL of a pat image/gif | | ||
| `hug` | Gets a URL of a hug image/gif | | ||
| `feed` | Gets a URL of a feed image/gif | | ||
| `slap` | Gets a URL of a slap image/gif | | ||
### Validations | ||
@@ -36,0 +26,0 @@ |
/** | ||
* `If the color argument is passed, then log the text in that color, otherwise just log the text.` | ||
* @param text - The text to be logged. | ||
* @param color - The color of the text. | ||
* @returns The function log is being returned. | ||
*/ | ||
/** | ||
* @description `If the color argument is passed, then log the text in that color, otherwise just log the text.` | ||
* @description Make a log with or without color | ||
* @author Zastinian | ||
@@ -17,2 +11,3 @@ * @param {String} text | ||
*/ | ||
function log(text, color) { | ||
@@ -26,3 +21,2 @@ if (color) { | ||
/* Exporting the function log. */ | ||
module.exports = log |
/** | ||
* It takes a string and returns a number of milliseconds | ||
* @param ms - The time in milliseconds. | ||
* @returns The number of milliseconds in the given time. | ||
*/ | ||
/** | ||
* @description Converts the indicated time to milliseconds | ||
@@ -20,2 +15,3 @@ * @author Zastinian | ||
*/ | ||
function millisecond(ms) { | ||
@@ -115,3 +111,2 @@ var type = typeof ms, | ||
/* Exporting the function `millisecond` to be used in other files. */ | ||
module.exports = millisecond |
/** | ||
* `random(min, max)` returns a random integer between `min` and `max` (inclusive). | ||
* | ||
* If you only pass in one argument, it will return a random integer between 0 and `min` (inclusive). | ||
* @param min - The minimum number to return. | ||
* @param max - The maximum number to generate. | ||
* @returns a random number between the min and max values. | ||
*/ | ||
/** | ||
* @description `random(min, max)` returns a random integer between `min` and `max` (inclusive). | ||
* | ||
* If you only pass in one argument, it will return a random integer between 0 and `min` (inclusive). | ||
* @description Get a random number between 2 numbers | ||
* @author Zastinian | ||
@@ -20,2 +10,3 @@ * @param {Number} min | ||
*/ | ||
function random(min, max) { | ||
@@ -27,3 +18,2 @@ if (!max) return min | ||
/* Exporting the function so that it can be used in other files. */ | ||
module.exports = random |
/** | ||
* It takes an array as an argument and returns a random item from that array | ||
* @param items - The array of items to choose from. | ||
* @returns a random item from the array. | ||
*/ | ||
/** | ||
* @description It takes an array as an argument and returns a random item from that array | ||
* @description Get a random element from an array | ||
* @author Zastinian | ||
@@ -14,2 +9,3 @@ * @param {Array} items | ||
*/ | ||
function randomItem(items) { | ||
@@ -19,3 +15,2 @@ return items[Math.floor(Math.random() * items.length)] | ||
/* Exporting the function so that it can be used in other files. */ | ||
module.exports = randomItem |
@@ -1,4 +0,3 @@ | ||
/* It's a list of symbols. */ | ||
/** | ||
* @description It's a list of symbols. | ||
* @description Returns a selected symbol | ||
* @author Zastinian | ||
@@ -10,2 +9,3 @@ * @param {String} symbols.Symbol | ||
*/ | ||
module.exports = { | ||
@@ -12,0 +12,0 @@ square: "█", |
/** | ||
* It returns the type of the object passed to it | ||
* @param obj - The object to test | ||
* @returns The type of the object. | ||
*/ | ||
/** | ||
* @description It returns the type of the object passed to it | ||
* @description Check what type is provided | ||
* @author Zastinian | ||
@@ -18,2 +13,3 @@ * @param {any} obj | ||
*/ | ||
function type(obj) { | ||
@@ -61,3 +57,2 @@ var undef | ||
/* Exporting the function `type` as a module. */ | ||
module.exports = type |
@@ -1,2 +0,1 @@ | ||
/* Exporting a function that returns a promise that resolves after a certain amount of time. */ | ||
/** | ||
@@ -14,2 +13,3 @@ * @description Execute the code after a while | ||
*/ | ||
module.exports = (delay = 0) => new Promise((resolve) => setTimeout(resolve, delay)) |
/** | ||
* If the value is an empty string, return true, otherwise return false. | ||
* @param value - The value to check. | ||
* @returns true | ||
*/ | ||
/** | ||
* @description If the value is an empty string, return true, otherwise return false. | ||
* @description Check if the text is not empty | ||
* @author Zastinian | ||
@@ -14,2 +9,3 @@ * @param {String} value | ||
*/ | ||
function isEmptyString(value) { | ||
@@ -19,3 +15,2 @@ return value === "" | ||
/* Exporting the function to be used in other files. */ | ||
module.exports = isEmptyString |
/** | ||
* If the email address contains no @ symbol, or more than one @ symbol, or is longer than 256 | ||
* characters, or the account name is longer than 64 characters, or the domain name is longer than 255 | ||
* characters, or any of the domain parts are longer than 63 characters, or the email fails the regex | ||
* test, then the email address is invalid. | ||
* @param email - The email address to validate. | ||
* @returns A boolean value. | ||
*/ | ||
/** | ||
* @description If the email address contains no @ symbol, or more than one @ symbol, or is longer than 256 | ||
* characters, or the account name is longer than 64 characters, or the domain name is longer than 255 | ||
* characters, or any of the domain parts are longer than 63 characters, or the email fails the regex | ||
* test, then the email address is invalid. | ||
* @description Check if it is a email | ||
* @author Zastinian | ||
@@ -20,2 +9,3 @@ * @param {String} email | ||
*/ | ||
function isValidEmail(email) { | ||
@@ -42,3 +32,2 @@ if (!email) return false | ||
/* Exporting the function to be used in other files. */ | ||
module.exports = isValidEmail |
/** | ||
* It returns true if the number is a valid number, otherwise it returns false. | ||
* @param number - The number to be validated. | ||
* @returns A boolean value. | ||
*/ | ||
/** | ||
* @description It returns true if the number is a valid number, otherwise it returns false. | ||
* @description Check if it is a number | ||
* @author Zastinian | ||
@@ -14,2 +9,3 @@ * @param {Number} number | ||
*/ | ||
function isValidNumber(number) { | ||
@@ -19,3 +15,2 @@ return /^[0-9]+$/.test(number) | ||
/* Exporting the function to be used in other files. */ | ||
module.exports = isValidNumber |
/** | ||
* It checks if the content is a valid URL by checking if it matches the pattern of a URL. | ||
* @param content - The content to be validated. | ||
* @returns A boolean value. | ||
*/ | ||
/** | ||
* @description It checks if the content is a valid URL by checking if it matches the pattern of a URL. | ||
* @description Check that the text is a link | Only texts with http: or https: | ||
* @author Zastinian | ||
@@ -15,16 +10,13 @@ * @param {String} content | ||
*/ | ||
function isValidUrl(content) { | ||
var pattern = new RegExp( | ||
"^(https?:\\/\\/)?" + | ||
"((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + | ||
"((\\d{1,3}\\.){3}\\d{1,3}))" + | ||
"(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + | ||
"(\\?[;&a-z\\d%_.~+=-]*)?" + | ||
"(\\#[-a-z\\d_]*)?$", | ||
"i" | ||
) | ||
return !!pattern.test(content) | ||
function isValidUrl(content, whitelist = []) { | ||
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 | ||
} | ||
/* Exporting the function to be used in other files. */ | ||
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
0
0
90406
19
3221
59
- Removednode-fetch@^3.2.10
- Removeddata-uri-to-buffer@4.0.1(transitive)
- Removedfetch-blob@3.2.0(transitive)
- Removedformdata-polyfill@4.0.10(transitive)
- Removednode-domexception@1.0.0(transitive)
- Removednode-fetch@3.3.2(transitive)
- Removedweb-streams-polyfill@3.3.3(transitive)