diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index f66c1f9..a4cfe69 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,8 +1,8 @@ # These are supported funding model platforms -github: [Ali-Eldeba, Omar khaled] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -# patreon: alieldeba # Replace with a single Patreon username -# open_collective: # Replace with a single Open Collective username +# github: Ali-Eldeba # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: alieldeba # Replace with a single Patreon username +open_collective: alieldeba # Replace with a single Open Collective username # ko_fi: # Replace with a single Ko-fi username # tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel # community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry @@ -10,4 +10,4 @@ github: [Ali-Eldeba, Omar khaled] # Replace with up to 4 GitHub Sponsors-enabled # issuehunt: # Replace with a single IssueHunt username # otechie: # Replace with a single Otechie username # lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry - custom: [https://www.buymeacoffee.com/alieldeba] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] +# custom: [https://www.buymeacoffee.com/alieldeba] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.gitignore b/.gitignore index 6a60a8e..1122c7d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,7 @@ ehthumbs_vista.db *.msi *.msix *.msm -*.msp \ No newline at end of file +*.msp + +# Small Unimportant files +futureFunctions.txt \ No newline at end of file diff --git a/LICENSE b/LICENSE index 23727dd..4436283 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ MIT License Copyright (c) 2022 Functionalty.js -Copyright (c) 2022 Ali-Eldeba +Copyright (c) 2022 alieldeba Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index f6e787f..af5204a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -

+

-#

Functionality.js (beta) 🔥

+#

Functionality.js

- + - +

@@ -21,10 +21,16 @@ - So To Get Started Using Functionalty.js Library,
You Have To Install It By npm - ```cmd + ```sh npm install functionality.js ``` -- Or You Can Install it By CDN In Your HTML File +- Or You Can Install it By yarn In Your HTML File + + ```sh + yarn add functionality.js + ``` + +- Or Even You Can Get it By CDN ```html @@ -51,7 +57,7 @@ You Can Import Unminified Version ```html - import functionality from "functionality.js/lib/main"; + import functionality from "functionality.js"; ``` - Since You Have Downloaded And Imported The Library You Can Use It As Following ... @@ -62,41 +68,32 @@ - You Can Visit Functionalty.js Site From Here - Or This is A Quick Start From Here -#

Here Is What We Are Working On 🤞

- -1. Adding Logo -2. ✔️ Converting Library Into TypeScript -3. ✔️ Making File Supported By All Of Search Engines -4. ✔️ Making File Compressed -5. ✔️ Making File Light Weight -6. ✔️ Testing The Library -7. ✔️ Handling Function Errors -8. Making A Documentation Website -9. Adding Dark And White Theme In Website -10. ✔️ Adding New Functions -11. ✔️ Making npm Package For Installation -12. ✔️ Making a CDN Importing - #

Feel Free To Contribute To This Repositry 🤝

## To Get Started Contributing ☕ - First Clone The Repository - ```cmd - git clone https://github.com/Ali-Eldeba/functionality.js.git + ```sh + git clone https://github.com/alieldeba/functionality.js.git ``` - Then Install Packages (node_modules) - ```cmd + ```sh npm install ``` - Run Website In Your Locahost Server With Live Reload - ```cmd - npm start + ```sh + npm run dev + ``` + +- Run the Build + + ```sh + npm run build-npm ``` - Feel Free To Add What You Want! diff --git a/dist/functionality.min.js b/dist/functionality.min.js index 65f1c9d..52a74c3 100644 --- a/dist/functionality.min.js +++ b/dist/functionality.min.js @@ -1 +1 @@ -const x=function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const n of o)if(n.type==="childList")for(const a of n.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(o){const n={};return o.integrity&&(n.integrity=o.integrity),o.referrerpolicy&&(n.referrerPolicy=o.referrerpolicy),o.crossorigin==="use-credentials"?n.credentials="include":o.crossorigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(o){if(o.ep)return;o.ep=!0;const n=t(o);fetch(o.href,n)}};x();function u(e){if(!Array.isArray(e)||e.some(r=>typeof r!="number"))throw new TypeError("Expected an array of numbers but got "+(Array.isArray(e)?"array":typeof e));return e.reduce((r,t)=>r+t,0)}function f(e){if(typeof e!="string")throw new TypeError("Expected a string but got "+typeof e);return e?e.charAt(0).toUpperCase()+e.slice(1):""}function s(e,r){if(!Array.isArray(e))throw new TypeError("Expected an array but got "+typeof e);return e.filter(t=>t!=r)}function c(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);return[...Array(e+1).keys()].filter(r=>e%r===0)}function y(e=0,r){return typeof e!="number"&&!r?0:!r&&typeof+e=="number"?e:isNaN(+e)||isNaN(+r)?0:Math.floor((+e+ +r)/2)}function d(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);return e%2==0}function h(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);return e%2!=0}function p(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);for(let r=2,t=Math.sqrt(e);r<=t;r++)if(e%r===0)return!1;return!0}function g(e){if(!Array.isArray(e))throw new TypeError("Expected an array but got "+typeof e);return Math.max(...e)}function m(e){if(!Array.isArray(e))throw new TypeError("Expected an array but got "+typeof e);return Math.min(...e)}function w(){return Math.random()>=.5}function M(e){if(!Array.isArray(e))throw new TypeError("Expected an array but got "+typeof e);return e[Math.floor(Math.random()*e.length)]}function S(){return`#${Math.floor(Math.random()*16777215).toString(16).padEnd(6,"0")}`}function E(e,r){if(typeof e!="number"||typeof r!="number")throw new TypeError("Expected numbers but got "+typeof e+" and "+typeof r);return Math.floor(Math.random()*(r-e+1)+e)}function G(e){if(!Array.isArray(e))throw new TypeError("Expected an array but got "+typeof e);e.filter(function(r,t){return[...new Set(e)]})}function k(e){if(typeof e!="string")throw new TypeError("Expected a string but got "+typeof e);return!e||typeof e!="string"?"":e.split("").reverse().join("")}function A(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);if(e==0)return 0;if(e<10&&e>-10)return e;const r=+(e>10?e:e*-1).toString().split("").reverse().join("");return e>10?r:r*-1}function B(e){if(!Array.isArray(e))throw new TypeError("Expected an array");return e.sort((r,t)=>.5-Math.random())}function L(e=5){if(typeof e!="number")throw new TypeError("Expected numbers but got "+typeof e);for(var r="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=t.length,o=0;o0;)t+=Math.pow(e%10,2),e=Math.floor(e/10);e=t}return e===1}function P(){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()_-+={[}]|\\:;\"'<,>.?/~`!";let r="";for(let t=0;t<12;t++)r+=e[Math.floor(Math.random()*e.length)];return r}const l={sumOfArray:u,capitalize:f,filterArray:s,getFactors:c,getMid:y,isEven:d,isOdd:h,isPrime:p,isPalindrome:b,maxArray:g,minArray:m,randomBoolean:w,randomElementFrom:M,randomHex:S,randomNumber:E,removeDuplicate:G,reverseString:k,reverseNumber:A,shuffle:B,randomString:L,randomColor:D,randomHsl:v,isHappyNumber:T,randomPassword:P};window.functionality=l;function b(e){if(typeof e!="string")throw new TypeError("Expected a string but got "+typeof e);return e.toString()==l.reverseString(e.toString())}const O={sumOfArray:u,capitalize:f,filterArray:s,getFactors:c,getMid:y,isEven:d,isOdd:h,isPrime:p,isPalindrome:b,maxArray:g,minArray:m,randomBoolean:w,randomElementFrom:M,randomHex:S,randomNumber:E,removeDuplicate:G,reverseString:k,reverseNumber:A,shuffle:B,randomString:L,randomColor:D,randomHsl:v,isHappyNumber:T,randomPassword:P};window.functionality=O;console.log(l.reverseNumber(123)); +const U=function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const o of n)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(n){const o={};return n.integrity&&(o.integrity=n.integrity),n.referrerpolicy&&(o.referrerPolicy=n.referrerpolicy),n.crossorigin==="use-credentials"?o.credentials="include":n.crossorigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(n){if(n.ep)return;n.ep=!0;const o=t(n);fetch(n.href,o)}};U();function l(e){if(!Array.isArray(e)||e.some(r=>typeof r!="number"))throw new TypeError("Expected an array of numbers but got "+(Array.isArray(e)?"array":typeof e));return e.reduce((r,t)=>r+t,0)}function c(e){if(typeof e!="string")throw new TypeError("Expected a string but got "+typeof e);return e?e.charAt(0).toUpperCase()+e.slice(1):""}function s(e,r){if(!Array.isArray(e))throw new TypeError("Expected an array but got "+typeof e);return e.filter(t=>t!=r)}function p(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);return[...Array(e+1).keys()].filter(r=>e%r===0)}function y(e=0,r){return typeof e!="number"&&!r?0:!r&&typeof+e=="number"?e:isNaN(+e)||isNaN(+r)?0:Math.floor((+e+ +r)/2)}function h(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);return e%2==0}function d(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);return e%2!=0}function g(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);for(let r=2,t=Math.sqrt(e);r<=t;r++)if(e%r===0)return!1;return!0}function m(e){if(!Array.isArray(e))throw new TypeError("Expected an array but got "+typeof e);return Math.max(...e)}function w(e){if(!Array.isArray(e))throw new TypeError("Expected an array but got "+typeof e);return Math.min(...e)}function M(){return Math.random()>=.5}function E(e){if(!Array.isArray(e))throw new TypeError("Expected an array but got "+typeof e);return e[Math.floor(Math.random()*e.length)]}function S(){return`#${Math.floor(Math.random()*16777215).toString(16).padEnd(6,"0")}`}function b(e,r){if(typeof e!="number"||typeof r!="number")throw new TypeError("Expected numbers but got "+typeof e+" and "+typeof r);return Math.floor(Math.random()*(r-e+1)+e)}function k(e){if(!Array.isArray(e))throw new TypeError("Expected an array but got "+typeof e);e.filter(function(r,t){return[...new Set(e)]})}function B(e){if(typeof e!="string")throw new TypeError("Expected a string but got "+typeof e);return!e||typeof e!="string"?"":e.split("").reverse().join("")}function G(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);if(e==0)return 0;if(e<10&&e>-10)return e;const r=+(e>10?e:e*-1).toString().split("").reverse().join("");return e>10?r:r*-1}function T(e){return e.toString().replace(new RegExp("\\B(?.5-Math.random())}function A(e=5){if(typeof e!="number")throw new TypeError("Expected numbers but got "+typeof e);for(var r="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=t.length,n=0;n0;)t+=Math.pow(e%10,2),e=Math.floor(e/10);e=t}return e===1}function P(){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()_-+={[}]|\\:;\"'<,>.?/~`!";let r="";for(let t=0;t<12;t++)r+=e[Math.floor(Math.random()*e.length)];return r}function C(e,r,t){return"#"+((1<<24)+(e<<16)+(r<<8)+t).toString(16).slice(1)}function O(e){return e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(r,t,i,n)=>"#"+t+t+i+i+n+n).substring(1).match(/.{2}/g).map(r=>parseInt(r,16))}function R(e,r,t){e/=255,r/=255,t/=255;var i=Math.max(e,r,t),n=Math.min(e,r,t),o,a,f=(i+n)/2;if(i==n)o=a=0;else{var u=i-n;switch(a=f>.5?u/(2-i-n):u/(i+n),i){case e:o=(r-t)/u+(r(a+e/30)%12,n=r*Math.min(t,1-t),o=a=>t-n*Math.max(-1,Math.min(i(a)-3,Math.min(9-i(a),1)));return[Math.trunc(255*o(0)),Math.trunc(255*o(8)),Math.trunc(255*o(4))]}function W(e){if(typeof e!="string")throw new TypeError("Expected a string but got "+typeof e);return e.replace(/\s+/g," ")}function q(){return navigator.userAgent.split(" ")[navigator.userAgent.split(" ").length-1]}function F(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);return e*12}function Y(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);return e*12*4}function H(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);return e*12*4*7}function $(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);return e*12*7*4*24}function I(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);return e*12*7*4*24*60}function V(e){if(typeof e!="number")throw new TypeError("Expected a number but got "+typeof e);return e*12*7*4*24*60*60}function _(e){var r=new Date,t=r.getFullYear();return t-e}function j(e){if(typeof e!="string")throw new TypeError("Expected a string but got "+typeof e);return document.querySelector(e)}const K={sumOfArray:l,capitalize:c,filterArray:s,getFactors:p,getMid:y,isEven:h,isOdd:d,isPrime:g,isPalindrome:z,maxArray:m,minArray:w,randomBoolean:M,randomElementFrom:E,randomHex:S,randomNumber:b,addCommas:T,removeDuplicate:k,reverseString:B,reverseNumber:G,shuffle:v,randomString:A,randomColor:D,randomHsl:x,isHappyNumber:L,randomPassword:P,rgbToHex:C,hexToRgb:O,rgbToHsl:R,hslToRgb:N,removeInnerSpace:W,getBrowser:q,getMonths:F,getWeeks:Y,getDays:H,getHours:$,getSeconds:V,getMinutes:I,getBirthDay:_,select:j};window.functionality=K;function z(e){if(typeof e!="string")throw new TypeError("Expected a string but got "+typeof e);return e.toString()==K.reverseString(e.toString())}function J(e){var r=new Date,t=r.getFullYear();return t-e}const Q={sumOfArray:l,capitalize:c,filterArray:s,getFactors:p,getMid:y,isEven:h,isOdd:d,isPrime:g,isPalindrome:z,maxArray:m,minArray:w,randomBoolean:M,randomElementFrom:E,randomHex:S,randomNumber:b,addCommas:T,removeDuplicate:k,reverseString:B,reverseNumber:G,shuffle:v,randomString:A,randomColor:D,randomHsl:x,isHappyNumber:L,randomPassword:P,rgbToHex:C,hexToRgb:O,rgbToHsl:R,hslToRgb:N,removeInnerSpace:W,getBrowser:q,getMonths:F,getWeeks:Y,getDays:H,getHours:$,getMinutes:I,getSeconds:V,getBirthday:J,select:j};window.functionality=Q; diff --git a/dist/index.html b/dist/index.html index 411e5d0..19fbc02 100644 --- a/dist/index.html +++ b/dist/index.html @@ -1,13 +1,24 @@ - - - Title - - - - - - - - \ No newline at end of file + + + functionality.js + + + + +

Thanks for contributing to functionality.js Library ❤🙏

+ + + + diff --git a/functionalty.zip b/functionalty.zip deleted file mode 100644 index 09ed820..0000000 Binary files a/functionalty.zip and /dev/null differ diff --git a/futureFunctions.txt b/futureFunctions.txt index 83ec111..f1be9f8 100644 --- a/futureFunctions.txt +++ b/futureFunctions.txt @@ -1,6 +1 @@ -- Arrays - - zip -- Strings -- Numbers -- Numbers -- randoms \ No newline at end of file +- zip \ No newline at end of file diff --git a/index.js b/index.js index f4a3b38..8ea1234 100644 --- a/index.js +++ b/index.js @@ -1 +1,2 @@ -export {default as functionality} from './lib/main.js'; +import functionality from './lib/main.js'; +export default functionality diff --git a/lib/converts/hexToHsl.d.ts b/lib/converts/hexToHsl.d.ts new file mode 100644 index 0000000..3ddab6e --- /dev/null +++ b/lib/converts/hexToHsl.d.ts @@ -0,0 +1 @@ +export default function hexToHsl(hex: string): number[]; diff --git a/lib/converts/hexToHsl.js b/lib/converts/hexToHsl.js new file mode 100644 index 0000000..96caf05 --- /dev/null +++ b/lib/converts/hexToHsl.js @@ -0,0 +1,30 @@ +export default function hexToHsl(hex) { + let rgb = hex + .replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => "#" + r + r + g + g + b + b) + .substring(1) + .match(/.{2}/g) + .map((x) => parseInt(x, 16)); + (rgb[0] /= 255), (rgb[1] /= 255), (rgb[2] /= 255); + var max = Math.max(rgb[0], rgb[1], rgb[2]), min = Math.min(rgb[0], rgb[1], rgb[2]); + var h, s, l = (max + min) / 2; + if (max == min) { + h = s = 0; + } + else { + var d = max - min; + s = l > 0.5 ? d / (2 - max - min) : d / (max + min); + switch (max) { + case rgb[0]: + h = (rgb[1] - rgb[2]) / d + (rgb[1] < rgb[2] ? 6 : 0); + break; + case rgb[1]: + h = (rgb[2] - rgb[1]) / d + 2; + break; + case rgb[2]: + h = (rgb[0] - rgb[1]) / d + 4; + break; + } + h /= 6; + } + return [h, s, l]; +} diff --git a/lib/converts/hslToRgb.d.ts b/lib/converts/hslToRgb.d.ts new file mode 100644 index 0000000..bc92384 --- /dev/null +++ b/lib/converts/hslToRgb.d.ts @@ -0,0 +1,9 @@ +/** + * Converts HSL color to RGB color + * + * @param {number} h + * @param {number} s + * @param {number} l + * @returns {number[]} + */ +export default function hslToRgb(h: number, s: number, l: number): number[]; diff --git a/lib/converts/hslToRgb.js b/lib/converts/hslToRgb.js new file mode 100644 index 0000000..b00408a --- /dev/null +++ b/lib/converts/hslToRgb.js @@ -0,0 +1,20 @@ +/** + * Converts HSL color to RGB color + * + * @param {number} h + * @param {number} s + * @param {number} l + * @returns {number[]} + */ +export default function hslToRgb(h, s, l) { + s /= 100; + l /= 100; + const k = (n) => (n + h / 30) % 12; + const a = s * Math.min(l, 1 - l); + const f = (n) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1))); + return [ + Math.trunc(255 * f(0)), + Math.trunc(255 * f(8)), + Math.trunc(255 * f(4)), + ]; +} diff --git a/lib/converts/rgbToHsl.d.ts b/lib/converts/rgbToHsl.d.ts index cde8e96..38e5ed3 100644 --- a/lib/converts/rgbToHsl.d.ts +++ b/lib/converts/rgbToHsl.d.ts @@ -1,8 +1,9 @@ /** + * Converts RGB Color To HSL * - * @param r - * @param g - * @param b - * @returns + * @param {number} r + * @param {number} g + * @param {number} b + * @returns {number[]} */ export default function rgbToHsl(r: number, g: number, b: number): number[]; diff --git a/lib/converts/rgbToHsl.js b/lib/converts/rgbToHsl.js index cd339d5..973c43e 100644 --- a/lib/converts/rgbToHsl.js +++ b/lib/converts/rgbToHsl.js @@ -1,9 +1,10 @@ /** + * Converts RGB Color To HSL * - * @param r - * @param g - * @param b - * @returns + * @param {number} r + * @param {number} g + * @param {number} b + * @returns {number[]} */ export default function rgbToHsl(r, g, b) { (r /= 255), (g /= 255), (b /= 255); diff --git a/lib/main.d.ts b/lib/main.d.ts index 5c297a6..2ce4447 100644 --- a/lib/main.d.ts +++ b/lib/main.d.ts @@ -16,6 +16,7 @@ import randomNumber from "./randoms/randomNumber"; import removeDuplicate from "./arrays/removeDuplicate"; import reverseString from "./strings/reverseString"; import reverseNumber from "./numbers/reverseNumber"; +import addCommas from "./numbers/addCommas"; import shuffle from "./arrays/shuffle"; import randomString from "./randoms/randomString"; import randomColor from "./randoms/randomColor"; @@ -25,6 +26,7 @@ import randomPassword from "./randoms/randomPassword"; import rgbToHex from "./converts/rgbToHex"; import hexToRgb from "./converts/hexToRgb"; import rgbToHsl from "./converts/rgbToHsl"; +import hslToRgb from "./converts/hslToRgb"; import removeInnerSpace from "./strings/removeInnerSpace"; import getBrowser from "./user/getBrowser"; import getMonths from "./user/getMonths"; @@ -33,6 +35,8 @@ import getDays from "./user/getDays"; import getHours from "./user/getHours"; import getMinutes from "./user/getMinutes"; import getSeconds from "./user/getSeconds"; +import getBirthday from "./user/getBirthday"; +import copy from "./user/copy"; import select from "./dom/select"; declare const functionality: { sumOfArray: typeof sumOfArray; @@ -50,6 +54,7 @@ declare const functionality: { randomElementFrom: typeof randomElementFrom; randomHex: typeof randomHex; randomNumber: typeof randomNumber; + addCommas: typeof addCommas; removeDuplicate: typeof removeDuplicate; reverseString: typeof reverseString; reverseNumber: typeof reverseNumber; @@ -62,14 +67,17 @@ declare const functionality: { rgbToHex: typeof rgbToHex; hexToRgb: typeof hexToRgb; rgbToHsl: typeof rgbToHsl; + hslToRgb: typeof hslToRgb; removeInnerSpace: typeof removeInnerSpace; getBrowser: typeof getBrowser; getMonths: typeof getMonths; getWeeks: typeof getWeeks; getDays: typeof getDays; getHours: typeof getHours; - getSeconds: typeof getSeconds; getMinutes: typeof getMinutes; + getSeconds: typeof getSeconds; + getBirthday: typeof getBirthday; + copy: typeof copy; select: typeof select; }; declare global { diff --git a/lib/main.js b/lib/main.js index fbfbc67..73d4f5a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -16,6 +16,7 @@ import randomNumber from "./randoms/randomNumber"; import removeDuplicate from "./arrays/removeDuplicate"; import reverseString from "./strings/reverseString"; import reverseNumber from "./numbers/reverseNumber"; +import addCommas from "./numbers/addCommas"; import shuffle from "./arrays/shuffle"; import randomString from "./randoms/randomString"; import randomColor from "./randoms/randomColor"; @@ -27,7 +28,7 @@ import hexToRgb from "./converts/hexToRgb"; import rgbToHsl from "./converts/rgbToHsl"; // import hexToHsl from "./converts/hexToHsl"; // import hslToHex from "./converts/hslToHex"; -// import hslToRgb from "./converts/hslToRgb"; +import hslToRgb from "./converts/hslToRgb"; import removeInnerSpace from "./strings/removeInnerSpace"; import getBrowser from "./user/getBrowser"; import getMonths from "./user/getMonths"; @@ -36,6 +37,8 @@ import getDays from "./user/getDays"; import getHours from "./user/getHours"; import getMinutes from "./user/getMinutes"; import getSeconds from "./user/getSeconds"; +import getBirthday from "./user/getBirthday"; +import copy from "./user/copy"; import select from "./dom/select"; const functionality = { sumOfArray, @@ -53,6 +56,7 @@ const functionality = { randomElementFrom, randomHex, randomNumber, + addCommas, removeDuplicate, reverseString, reverseNumber, @@ -65,14 +69,17 @@ const functionality = { rgbToHex, hexToRgb, rgbToHsl, + hslToRgb, removeInnerSpace, getBrowser, getMonths, getWeeks, getDays, getHours, - getSeconds, getMinutes, + getSeconds, + getBirthday, + copy, select, }; window.functionality = functionality; diff --git a/lib/numbers/addCommas.d.ts b/lib/numbers/addCommas.d.ts new file mode 100644 index 0000000..b73cc6c --- /dev/null +++ b/lib/numbers/addCommas.d.ts @@ -0,0 +1,7 @@ +/** + * Returns Number With Commas To Facilitate Reading | e.g 1000000 => 1,000,000 + * + * @param {number} number + * @returns {string} + */ +export default function addCommas(number: number): string; diff --git a/lib/numbers/addCommas.js b/lib/numbers/addCommas.js new file mode 100644 index 0000000..6a2c0e7 --- /dev/null +++ b/lib/numbers/addCommas.js @@ -0,0 +1,9 @@ +/** + * Returns Number With Commas To Facilitate Reading | e.g 1000000 => 1,000,000 + * + * @param {number} number + * @returns {string} + */ +export default function addCommas(number) { + return number.toString().replace(/\B(? 15 + * + * @param {number} year + * @returns {number} + */ +export default function getBirthday(year: number): number; diff --git a/lib/user/getBirthDay.js b/lib/user/getBirthDay.js new file mode 100644 index 0000000..7939aa5 --- /dev/null +++ b/lib/user/getBirthDay.js @@ -0,0 +1,11 @@ +/** + * Returns the Age From a Given Year | e.g 2007 -> 15 + * + * @param {number} year + * @returns {number} + */ +export default function getBirthday(year) { + var currentDate = new Date(); + var currentYear = currentDate.getFullYear(); + return currentYear - year; +} diff --git a/package-lock.json b/package-lock.json index 2eef772..2cf416b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "functionality", - "version": "1.0.0", + "name": "functionality.js", + "version": "3.2.3", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "functionality", - "version": "1.0.0", + "name": "functionality.js", + "version": "3.2.3", "license": "ISC", "dependencies": { "@types/node": "^17.0.42", diff --git a/package.json b/package.json index 33b948a..9836d0b 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,16 @@ { "name": "functionality.js", "entry": "index.js", - "version": "3.2.1", + "version": "3.2.4", "description": "- This Is A JavaScript Library To Make Your Work Easier/Faster,
\r You Can See Functionalty.js Website From Here\r - Born In May 5 / 16 / 2022", + "homepage": "https://github.com/alieldeba/functionalty.js#readme", + "author": "alieldeba", "main": "index.js", + "keywords": [ + "functionality", + "javascript", + "modules" + ], "scripts": { "test": "jest --watchAll", "dev": "node server.js", @@ -12,14 +19,12 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/Ali-Eldeba/functionalty.js.git" + "url": "git+https://github.com/alieldeba/functionalty.js.git" }, - "author": "Ali-Eldeba", "license": "ISC", "bugs": { - "url": "https://github.com/Ali-Eldeba/functionalty.js/issues" + "url": "https://github.com/alieldeba/functionalty.js/issues" }, - "homepage": "https://github.com/Ali-Eldeba/functionalty.js#readme", "devDependencies": { "jest": "^26.6.3", "sass": "^1.52.0", diff --git a/project/ts/functionality/arrays/ascending.ts b/project/arrays/ascending.ts similarity index 100% rename from project/ts/functionality/arrays/ascending.ts rename to project/arrays/ascending.ts diff --git a/project/ts/functionality/arrays/descending.ts b/project/arrays/descending.ts similarity index 100% rename from project/ts/functionality/arrays/descending.ts rename to project/arrays/descending.ts diff --git a/project/ts/functionality/arrays/filterArray.ts b/project/arrays/filterArray.ts similarity index 100% rename from project/ts/functionality/arrays/filterArray.ts rename to project/arrays/filterArray.ts diff --git a/project/ts/functionality/arrays/getFactors.ts b/project/arrays/getFactors.ts similarity index 100% rename from project/ts/functionality/arrays/getFactors.ts rename to project/arrays/getFactors.ts diff --git a/project/ts/functionality/arrays/maxArray.ts b/project/arrays/maxArray.ts similarity index 100% rename from project/ts/functionality/arrays/maxArray.ts rename to project/arrays/maxArray.ts diff --git a/project/ts/functionality/arrays/minArray.ts b/project/arrays/minArray.ts similarity index 100% rename from project/ts/functionality/arrays/minArray.ts rename to project/arrays/minArray.ts diff --git a/project/ts/functionality/arrays/randomElementFrom.ts b/project/arrays/randomElementFrom.ts similarity index 100% rename from project/ts/functionality/arrays/randomElementFrom.ts rename to project/arrays/randomElementFrom.ts diff --git a/project/ts/functionality/arrays/removeDuplicate.ts b/project/arrays/removeDuplicate.ts similarity index 100% rename from project/ts/functionality/arrays/removeDuplicate.ts rename to project/arrays/removeDuplicate.ts diff --git a/project/ts/functionality/arrays/shuffle.ts b/project/arrays/shuffle.ts similarity index 100% rename from project/ts/functionality/arrays/shuffle.ts rename to project/arrays/shuffle.ts diff --git a/project/ts/functionality/arrays/sumOfArray.ts b/project/arrays/sumOfArray.ts similarity index 100% rename from project/ts/functionality/arrays/sumOfArray.ts rename to project/arrays/sumOfArray.ts diff --git a/project/ts/functionality/converts/hexToRgb.ts b/project/converts/hexToRgb.ts similarity index 100% rename from project/ts/functionality/converts/hexToRgb.ts rename to project/converts/hexToRgb.ts diff --git a/project/ts/functionality/converts/hslToHex.ts b/project/converts/hslToHex.ts similarity index 100% rename from project/ts/functionality/converts/hslToHex.ts rename to project/converts/hslToHex.ts diff --git a/project/converts/hslToRgb.ts b/project/converts/hslToRgb.ts new file mode 100644 index 0000000..9ea5f1f --- /dev/null +++ b/project/converts/hslToRgb.ts @@ -0,0 +1,21 @@ +/** + * Converts HSL color to RGB color + * + * @param {number} h + * @param {number} s + * @param {number} l + * @returns {number[]} + */ +export default function hslToRgb(h: number, s: number, l: number): number[] { + s /= 100; + l /= 100; + const k = (n: number) => (n + h / 30) % 12; + const a = s * Math.min(l, 1 - l); + const f = (n: number) => + l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1))); + return [ + Math.trunc(255 * f(0)), + Math.trunc(255 * f(8)), + Math.trunc(255 * f(4)), + ]; +} diff --git a/project/ts/functionality/converts/rgbToHex.ts b/project/converts/rgbToHex.ts similarity index 100% rename from project/ts/functionality/converts/rgbToHex.ts rename to project/converts/rgbToHex.ts diff --git a/project/ts/functionality/converts/rgbToHsl.ts b/project/converts/rgbToHsl.ts similarity index 84% rename from project/ts/functionality/converts/rgbToHsl.ts rename to project/converts/rgbToHsl.ts index 8ece733..740dd9c 100644 --- a/project/ts/functionality/converts/rgbToHsl.ts +++ b/project/converts/rgbToHsl.ts @@ -1,9 +1,10 @@ /** + * Converts RGB Color To HSL * - * @param r - * @param g - * @param b - * @returns + * @param {number} r + * @param {number} g + * @param {number} b + * @returns {number[]} */ export default function rgbToHsl(r: number, g: number, b: number): number[] { (r /= 255), (g /= 255), (b /= 255); diff --git a/project/ts/functionality/dom/select.ts b/project/dom/select.ts similarity index 84% rename from project/ts/functionality/dom/select.ts rename to project/dom/select.ts index f2ac74c..7dacd4f 100644 --- a/project/ts/functionality/dom/select.ts +++ b/project/dom/select.ts @@ -1,5 +1,5 @@ /** - * returns the number of Seconds in a given age + * gets HTML dom element * * @param {string} element * @returns {number} diff --git a/project/index.html b/project/index.html new file mode 100644 index 0000000..0bdc08b --- /dev/null +++ b/project/index.html @@ -0,0 +1,25 @@ + + + + + functionality.js + + + +

Thanks for contributing to functionality.js Library ❤🙏

+ + + + diff --git a/project/ts/functionality/main.js b/project/main.js similarity index 62% rename from project/ts/functionality/main.js rename to project/main.js index 76a682a..79fa3fd 100644 --- a/project/ts/functionality/main.js +++ b/project/main.js @@ -16,12 +16,29 @@ import randomNumber from "./randoms/randomNumber"; import removeDuplicate from "./arrays/removeDuplicate"; import reverseString from "./strings/reverseString"; import reverseNumber from "./numbers/reverseNumber"; +import addCommas from "./numbers/addCommas"; import shuffle from "./arrays/shuffle"; import randomString from "./randoms/randomString"; import randomColor from "./randoms/randomColor"; import randomHsl from "./randoms/randomHsl"; import isHappyNumber from "./numbers/isHappyNumber"; import randomPassword from "./randoms/randomPassword"; +import rgbToHex from "./converts/rgbToHex"; +import hexToRgb from "./converts/hexToRgb"; +import rgbToHsl from "./converts/rgbToHsl"; +// import hexToHsl from "./converts/hexToHsl"; +// import hslToHex from "./converts/hslToHex"; +import hslToRgb from "./converts/hslToRgb"; +import removeInnerSpace from "./strings/removeInnerSpace"; +import getBrowser from "./user/getBrowser"; +import getMonths from "./user/getMonths"; +import getWeeks from "./user/getWeeks"; +import getDays from "./user/getDays"; +import getHours from "./user/getHours"; +import getMinutes from "./user/getMinutes"; +import getSeconds from "./user/getSeconds"; +import getBirthDay from "./user/getBirthDay"; +import select from "./dom/select"; const functionality = { sumOfArray, capitalize, @@ -38,6 +55,7 @@ const functionality = { randomElementFrom, randomHex, randomNumber, + addCommas, removeDuplicate, reverseString, reverseNumber, @@ -47,7 +65,20 @@ const functionality = { randomHsl, isHappyNumber, randomPassword, + rgbToHex, + hexToRgb, + rgbToHsl, + hslToRgb, + removeInnerSpace, + getBrowser, + getMonths, + getWeeks, + getDays, + getHours, + getSeconds, + getMinutes, + getBirthDay, + select, }; window.functionality = functionality; -// export * from "./sumOfArray"; export default functionality; diff --git a/project/ts/functionality/main.ts b/project/main.ts similarity index 91% rename from project/ts/functionality/main.ts rename to project/main.ts index 0537ab1..1e8fb35 100644 --- a/project/ts/functionality/main.ts +++ b/project/main.ts @@ -16,6 +16,7 @@ import randomNumber from "./randoms/randomNumber"; import removeDuplicate from "./arrays/removeDuplicate"; import reverseString from "./strings/reverseString"; import reverseNumber from "./numbers/reverseNumber"; +import addCommas from "./numbers/addCommas"; import shuffle from "./arrays/shuffle"; import randomString from "./randoms/randomString"; import randomColor from "./randoms/randomColor"; @@ -27,7 +28,7 @@ import hexToRgb from "./converts/hexToRgb"; import rgbToHsl from "./converts/rgbToHsl"; // import hexToHsl from "./converts/hexToHsl"; // import hslToHex from "./converts/hslToHex"; -// import hslToRgb from "./converts/hslToRgb"; +import hslToRgb from "./converts/hslToRgb"; import removeInnerSpace from "./strings/removeInnerSpace"; import getBrowser from "./user/getBrowser"; import getMonths from "./user/getMonths"; @@ -36,6 +37,8 @@ import getDays from "./user/getDays"; import getHours from "./user/getHours"; import getMinutes from "./user/getMinutes"; import getSeconds from "./user/getSeconds"; +import getBirthday from "./user/getBirthday"; +// import copy from "./user/copy"; import select from "./dom/select"; const functionality = { @@ -54,6 +57,7 @@ const functionality = { randomElementFrom, randomHex, randomNumber, + addCommas, removeDuplicate, reverseString, reverseNumber, @@ -66,14 +70,17 @@ const functionality = { rgbToHex, hexToRgb, rgbToHsl, + hslToRgb, removeInnerSpace, getBrowser, getMonths, getWeeks, getDays, getHours, - getSeconds, getMinutes, + getSeconds, + getBirthday, + // copy, select, }; diff --git a/project/numbers/addCommas.ts b/project/numbers/addCommas.ts new file mode 100644 index 0000000..5f3eb8c --- /dev/null +++ b/project/numbers/addCommas.ts @@ -0,0 +1,9 @@ +/** + * Returns Number With Commas To Facilitate Reading | e.g 1000000 => 1,000,000 + * + * @param {number} number + * @returns {string} + */ +export default function addCommas(number: number): string { + return number.toString().replace(/\B(? - - - - Title - - - - - - - \ No newline at end of file diff --git a/project/ts/functionality/user/getMinutes.ts b/project/ts/functionality/user/getMinutes.ts deleted file mode 100644 index b658d1b..0000000 --- a/project/ts/functionality/user/getMinutes.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * returns the number of minutes in a given age - * - * @param {number} age - * @returns {number} - */ -export default function getWeeks(age: number): number { - if (typeof age !== "number") { - throw new TypeError("Expected a number but got " + typeof age); - } - return age * 12 * 7 * 4 * 24 * 60; -} diff --git a/project/ts/functionality/user/getMonths.ts b/project/ts/functionality/user/getMonths.ts deleted file mode 100644 index 5b816ab..0000000 --- a/project/ts/functionality/user/getMonths.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * returns the months of the age - * - * @param {number} age - * @returns {number} - */ -export default function getMonths(age: number): number { - if (typeof age !== "number") { - throw new TypeError("Expected a number but got " + typeof age); - } - return age * 12; -} diff --git a/project/user/copy.ts b/project/user/copy.ts new file mode 100644 index 0000000..5eb60f1 --- /dev/null +++ b/project/user/copy.ts @@ -0,0 +1,14 @@ +/** + * It takes text to copy it to the user + * + * @param {string} text + */ +export default async function copy(text: string) { + try { + const toCopy = text || location.href; + await navigator.clipboard.writeText(toCopy); + console.log("Text or Page URL copied"); + } catch (err) { + console.error("Failed to copy: ", err); + } +} diff --git a/project/user/getBirthday.ts b/project/user/getBirthday.ts new file mode 100644 index 0000000..cf1cae2 --- /dev/null +++ b/project/user/getBirthday.ts @@ -0,0 +1,11 @@ +/** + * Returns the Age From a Given Year | e.g 2007 -> 15 + * + * @param {number} year + * @returns {number} + */ + export default function getBirthday(year: number): number { + var currentDate = new Date(); + var currentYear = currentDate.getFullYear(); + return currentYear - year; +} \ No newline at end of file diff --git a/project/ts/functionality/user/getBrowser.ts b/project/user/getBrowser.ts similarity index 100% rename from project/ts/functionality/user/getBrowser.ts rename to project/user/getBrowser.ts diff --git a/project/ts/functionality/user/getDays.ts b/project/user/getDays.ts similarity index 100% rename from project/ts/functionality/user/getDays.ts rename to project/user/getDays.ts diff --git a/project/ts/functionality/user/getHours.ts b/project/user/getHours.ts similarity index 80% rename from project/ts/functionality/user/getHours.ts rename to project/user/getHours.ts index 4e811a1..ddf3cce 100644 --- a/project/ts/functionality/user/getHours.ts +++ b/project/user/getHours.ts @@ -4,9 +4,9 @@ * @param {number} age * @returns {number} */ -export default function getHours(age: number): number { + export default function getHours(age: number): number { if (typeof age !== "number") { throw new TypeError("Expected a number but got " + typeof age); } return age * 12 * 7 * 4 * 24; -} +} \ No newline at end of file diff --git a/project/user/getMinutes.ts b/project/user/getMinutes.ts new file mode 100644 index 0000000..fd87544 --- /dev/null +++ b/project/user/getMinutes.ts @@ -0,0 +1,12 @@ +/** + * returns the number of minutes in a given age + * + * @param {number} age + * @returns {number} + */ + export default function getWeeks(age: number): number { + if (typeof age !== "number") { + throw new TypeError("Expected a number but got " + typeof age); + } + return age * 12 * 7 * 4 * 24 * 60; + } \ No newline at end of file diff --git a/project/user/getMonths.ts b/project/user/getMonths.ts new file mode 100644 index 0000000..eb10390 --- /dev/null +++ b/project/user/getMonths.ts @@ -0,0 +1,12 @@ +/** + * returns the months of the age + * + * @param {number} age + * @returns {number} + */ + export default function getMonths(age: number): number { + if (typeof age !== "number") { + throw new TypeError("Expected a number but got " + typeof age); + } + return age * 12; + } \ No newline at end of file diff --git a/project/ts/functionality/user/getSeconds.ts b/project/user/getSeconds.ts similarity index 50% rename from project/ts/functionality/user/getSeconds.ts rename to project/user/getSeconds.ts index a476c4c..2c979ea 100644 --- a/project/ts/functionality/user/getSeconds.ts +++ b/project/user/getSeconds.ts @@ -5,8 +5,8 @@ * @returns {number} */ export default function getSeconds(age: number): number { - if (typeof age !== "number") { - throw new TypeError("Expected a number but got " + typeof age); - } - return age * 12 * 7 * 4 * 24 * 60 * 60; -} \ No newline at end of file + if (typeof age !== "number") { + throw new TypeError("Expected a number but got " + typeof age); + } + return age * 12 * 7 * 4 * 24 * 60 * 60; + } \ No newline at end of file diff --git a/project/ts/functionality/user/getWeeks.ts b/project/user/getWeeks.ts similarity index 79% rename from project/ts/functionality/user/getWeeks.ts rename to project/user/getWeeks.ts index 8478812..dd702bf 100644 --- a/project/ts/functionality/user/getWeeks.ts +++ b/project/user/getWeeks.ts @@ -4,9 +4,9 @@ * @param {number} age * @returns {number} */ -export default function getWeeks(age: number): number { + export default function getWeeks(age: number): number { if (typeof age !== "number") { throw new TypeError("Expected a number but got " + typeof age); } return age * 12 * 4; -} +} \ No newline at end of file diff --git a/robots.txt b/robots.txt deleted file mode 100644 index 9e60f97..0000000 --- a/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Disallow: diff --git a/tsconfig.json b/tsconfig.json index b939474..7ead1ff 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "files": ["project/ts/functionality/main.ts"], + "files": ["project/main.ts"], "compilerOptions": { "noImplicitAny": true, "target": "es2015", diff --git a/tsconfig.npm.json b/tsconfig.npm.json index fb11725..ee97ccb 100644 --- a/tsconfig.npm.json +++ b/tsconfig.npm.json @@ -1,7 +1,7 @@ { - "files": ["project/ts/functionality/main.ts"], + "files": ["project/main.ts"], "compilerOptions": { - "rootDir": "project/ts/functionality", + "rootDir": "project/", "noImplicitAny": true, "target": "ES2020", "module": "ES2020", @@ -10,6 +10,5 @@ "declaration": true, "declarationDir": "./lib/", "outDir": "./lib/" - } -} \ No newline at end of file +} diff --git a/vite.config.ts b/vite.config.ts index 474a428..d1dc6af 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,19 +2,19 @@ import { defineConfig } from "vite"; export default defineConfig({ plugins: [], - root: "./project/ts/functionality", + root: "./project/", build: { - outDir: "./../../../dist", + outDir: "../dist", rollupOptions: { output: { - entryFileNames: "functionality.min.js", - } + entryFileNames: "functionality.min.js", + }, }, emptyOutDir: true, - assetsDir: "./../../../dist", + assetsDir: "../dist", watch: { buildDelay: 0, clearScreen: true, }, }, -}); \ No newline at end of file +}); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy