{"id":15901518,"url":"https://github.com/itz-hyperz/hyperz-utils","last_synced_at":"2025-11-03T18:52:51.590Z","repository":{"id":61432537,"uuid":"551523846","full_name":"Itz-Hyperz/hyperz-utils","owner":"Itz-Hyperz","description":"A simple utilities package that offers many different functions that could be of use to you when writing ExpressJS websites or Discord bots!","archived":false,"fork":false,"pushed_at":"2023-01-22T23:07:15.000Z","size":40,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-01T00:38:22.683Z","etag":null,"topics":["backend","cli","node-module","npm","package"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/hyperz-utils","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Itz-Hyperz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-14T15:04:00.000Z","updated_at":"2023-06-18T07:04:47.000Z","dependencies_parsed_at":"2023-02-12T18:46:17.261Z","dependency_job_id":null,"html_url":"https://github.com/Itz-Hyperz/hyperz-utils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Itz-Hyperz%2Fhyperz-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Itz-Hyperz%2Fhyperz-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Itz-Hyperz%2Fhyperz-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Itz-Hyperz%2Fhyperz-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Itz-Hyperz","download_url":"https://codeload.github.com/Itz-Hyperz/hyperz-utils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244079568,"owners_count":20394754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","cli","node-module","npm","package"],"created_at":"2024-10-06T11:04:51.007Z","updated_at":"2025-11-03T18:52:51.542Z","avatar_url":"https://github.com/Itz-Hyperz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hyperz Utilities\r\nA simple utilities package that offers many different functions that could be of use to you when writing ExpressJS websites or Discord bots!\r\n\r\n---\r\n\r\n# Functions / Exports\r\n- [figlify](#figlify)\r\n- [mdConvert](#mdConvert)\r\n- [generateRandom](#generateRandom)\r\n- [sanitize](#sanitize)\r\n- [saveFile](#saveFile)\r\n- [getDate](#fetchTime)\r\n- [fetchTime](#fetchTime)\r\n- [getRandomArray](#getRandomArray)\r\n- [checkIfHex](#checkIfHex)\r\n- [dirSize](#dirSize)\r\n- [getDiscountedValue](#getDiscountedValue)\r\n- [randomColor](#randomColor)\r\n\r\n---\r\n\r\n# figlify\r\nUsed to turn text into art!\r\n```js\r\n    const utils = require('hyperz-utils');\r\n    await utils.figlify(\"Hello World!\", { randFont: true, font: undefined });\r\n```\r\n\r\n# mdConvert\r\nConverts raw text/md to HTML compatible.\r\n```js\r\n    const utils = require('hyperz-utils');\r\n    let text = \"# Hello world!\";\r\n    let webPageContent = await utils.mdConvert(text);\r\n    res.render('index.ejs', { content: webPageContent }); // ExpressJS Framework Example\r\n```\r\n\r\n# generateRandom\r\nGenerate a random string of acceptable characters.\r\n```js\r\n    const utils = require('hyperz-utils');\r\n    let random = await utils.generateRandom(12) // How long the string should be\r\n    console.log(random);\r\n```\r\n\r\n# sanitize\r\nMake a string of text MySQL compatible to avoid injections.\r\n```js\r\n    const utils = require('hyperz-utils');\r\n    let text = \"oh hello world`; DROP DATABASE main;\";\r\n    let cleansed = await utils.sanitize(text, false) // boolean for \u003cscript\u003e replacement in HTML\r\n    await con.query(cleansed, function(err, row) {\r\n        if(err) throw err;\r\n    });\r\n```\r\n\r\n# saveFile\r\nDownload and save a file from a URL. (NodeJS File Downloader)\r\n```js\r\n    const utils = require('hyperz-utils');\r\n    utils.saveFile(\"https://hyperz.net/assets/logo.png\", \"hyperzlogo\", \"png\", \"./public/images\", false); // boolean is to clone files or not\r\n```\r\n\r\n# getDate\r\nGet the date and convert to string with NodeJS.\r\n```js\r\n    const utils = require('hyperz-utils');\r\n    let date = await utils.getDate();\r\n    console.log(date);\r\n```\r\n\r\n# fetchTime\r\nFetch the current time from a certain time zone.\r\n```js\r\n    const utils = require('hyperz-utils');\r\n    let time = await utils.fetchTime(\"America/New_York\", \"MM-DD-YYYY\"); // https://github.com/Itz-Hyperz/big-ben-bot/blob/main/timezones.json look at values\r\n    console.log(date);\r\n```\r\n\r\n# getRandomArray\r\nGet a random element from an array of strings.\r\n```js\r\n    const utils = require('hyperz-utils');\r\n    let array = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"];\r\n    let random = await utils.getRandomArray(array);\r\n    console.log(`you got: ${random}!`);\r\n```\r\n\r\n# checkIfHex\r\nCheck if the provided string is a valid color hex.\r\n```js\r\n    const utils = require('hyperz-utils');\r\n    let hex = \"#FFFFFF\";\r\n    let check = await utils.checkIfHex(hex);\r\n    if(!check.pass) hex = check.item; // Set to the proper hex value if it's not\r\n    console.log(hex);\r\n```\r\n\r\n# dirSize\r\nView the directory size of a folder.\r\n```js\r\n    const utils = require('hyperz-utils');\r\n    let size = await utils.dirSize(\"./src/images\");\r\n    console.log(size);\r\n```\r\n\r\n# getDiscountedValue\r\nGet the discounted amount of a total value.\r\n```js\r\nconst utils = require('hyperz-utils');\r\nlet totalValue = 34.99; // Price\r\nlet discount = 30; // 30%\r\nlet newValue = await utils.getDiscountedValue(totalValue, discount);\r\nconsole.log(newValue) // 10.497 (30% of 34.99)\r\n```\r\n\r\n# randomColor\r\nGet a random color logged to the console.\r\n```js\r\nconst utils = require('hyperz-utils');\r\nutils.randomColor(\"Wow a random color!!!\");\r\n```\r\n\r\n---\r\n\r\n# Credits\r\n[@Hyperz](https://hyperz.net) - *Creating the package.*\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitz-hyperz%2Fhyperz-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitz-hyperz%2Fhyperz-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitz-hyperz%2Fhyperz-utils/lists"}