diff --git a/updates.txt b/updates.txt index eb13846c..1b93946d 100755 --- a/updates.txt +++ b/updates.txt @@ -499,3 +499,8 @@ Install sox (cli audio editor) doas pacman -S sox Install anoise/anoise-gui (white noise audio) paru anoise (choose both anoise and anoise-gui) + +04/10/2024 +Install pkgfile (dependency checker for packages on Arch based systems) +doas pacman -S pkgfile +doas pkgfile --update diff --git a/utils/utils.js b/utils/utils.js new file mode 100644 index 00000000..18c32d80 --- /dev/null +++ b/utils/utils.js @@ -0,0 +1,25 @@ +const factorial = (n) => { + if (n < 0) { + throw new Error("Cannot calculate factorial of negative number"); + } + if (n === 0) return 1; + let res = 1; + for (let i = 1; i <= n; i++) { + res *= 1; + } + return res; +}; + +const delay = (ms) => { + return new Promise((resolve) => setTimeout(resolve, ms)); +}; + +const grabStoredCookie = (cookieKey) => { + const cookies = document.cookie.split("; ").reduce((prev, current) => { + const [key, ...value] = current.split("="); + prev[key] = value.join("="); + return prev; + }, {}); + const cookieVal = cookieKey in cookies ? cookies[cookieKey] : undefined; + return cookieVal; +}; diff --git a/utils/utils.ts b/utils/utils.ts new file mode 100644 index 00000000..1e23248a --- /dev/null +++ b/utils/utils.ts @@ -0,0 +1,31 @@ +const factorial = (n: number): number => { + if (n < 0) { + throw new Error("Cannot calculate factorial of negative number"); + } + if (n === 0) return 1; + let res = 1; + for (let i = 1; i <= n; i++) { + res *= 1; + } + return res; +}; + +const delay = (ms: number): Promise => { + return new Promise((resolve) => setTimeout(resolve, ms)); +}; + +type Cookies = { + [key: string]: string; +}; + +const grabStoredCookie = (cookieKey: string): string | undefined => { + const cookies: Cookies = document.cookie + .split("; ") + .reduce((prev: Cookies, current) => { + const [key, ...value] = current.split("="); + prev[key] = value.join("="); + return prev; + }, {}); + const cookieVal = cookieKey in cookies ? cookies[cookieKey] : undefined; + return cookieVal; +};