mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
22 lines
395 B
JavaScript
22 lines
395 B
JavaScript
'use strict';
|
|
|
|
const isFn = (a) => typeof a === 'function';
|
|
|
|
module.exports.btoa = (str) => {
|
|
if (typeof btoa === 'function')
|
|
return btoa(str);
|
|
|
|
return Buffer
|
|
.from(str)
|
|
.toString('base64');
|
|
};
|
|
|
|
module.exports.atob = (str) => {
|
|
if (isFn(atob))
|
|
return atob(str);
|
|
|
|
return Buffer
|
|
.from(str, 'base64')
|
|
.toString('binary');
|
|
};
|
|
|