Skip to content

Commit 0825ba2

Browse files
committed
Add base64
1 parent 1a22685 commit 0825ba2

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/util.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
var isFunction = function(fn) {
1+
const isFunction = function(fn) {
22
return fn && {}.toString.call(fn) === '[object Function]';
33
}
44

5+
const base64 = function(s) {
6+
global.window = {};
7+
if (window && window.btoa) {
8+
return window.btoa(s);
9+
}
10+
else if (Buffer) {
11+
return Buffer.from(s).toString('base64');
12+
}
13+
}
14+
515
module.exports = {
6-
isFunction: isFunction
16+
isFunction,
17+
base64
718
}

0 commit comments

Comments
 (0)