UNPKG
btoa
Version:
latest (1.2.1)
1.2.1
1.1.2
1.1.1
1.1.0
1.0.1
1.0.0
btoa for Node.JS (it's a one-liner)
git.coolaj86.com/coolaj86/btoa.js.git
btoa
/
index.js
18 lines
(13 loc)
•
273 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(
function
(
) {
"use strict"
;
function
btoa
(
str
) {
var
buffer;
if
(str
instanceof
Buffer
) { buffer = str; }
else
{ buffer =
Buffer
.
from
(str.
toString
(),
'binary'
); }
return
buffer.
toString
(
'base64'
); }
module
.
exports
= btoa; }());