How to use the base64-js.encode function in base64-js

To help you get started, we’ve selected a few base64-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SocketCluster / socketcluster-client / socketcluster.js View on Github external
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;
};

base64-js

Base64 encoding/decoding in pure JS

MIT
Latest version published 4 years ago

Package Health Score

74 / 100
Full package analysis