Created
November 2, 2021 13:42
-
-
Save DistractionBoy/915934c7431d81dc283f762703fde375 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* this function replaces atob() which is a method of the window object and does not run | |
* properly on node. it takes a base64 encoded string and DECODES it into a js obj | |
* ----found at ----> https://gist.github.com/oeon/0ada0457194ebf70ec2428900ba76255 | |
*/ | |
export const a2b = (a: string): string => { | |
let b, c, d | |
const e = {} | |
let f = 0 | |
let g = 0 | |
let h = '' | |
const i = String.fromCharCode | |
const j = a && a.length | |
for (b = 0; 64 > b; b++) | |
e['ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(b)] = b | |
for (c = 0; j > c; c++) | |
for (b = e[a.charAt(c)], f = (f << 6) + b, g += 6; g >= 8; ) | |
((d = 255 & (f >>> (g -= 8))) || j - 2 > c) && (h += i(d)) | |
return h | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment