Buffer
for the given string with binary encoding and use Buffer.toString('base64')
to return the encoded string.const btoa = str => Buffer.from(str, 'binary').toString('base64');
btoa('foobar'); // 'Zm9vYmFy'
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️