Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
SCSocket.prototype.encodeBase64 = function (decodedString) {
var encodedString;
if (typeof Buffer == 'undefined') {
if (global.btoa) {
encodedString = global.btoa(decodedString);
} else {
encodedString = base64.encode(decodedString);
}
} else {
var buffer = new Buffer(decodedString, 'utf8');
encodedString = buffer.toString('base64');
}
return encodedString;
};