How to use js-base64

Comprehensive js-base64 code examples:

How to use js-base64.atob:

41
42
43
44
45
46
47
48
49
50

fs.readFile(path, 'utf8', function (err, data) {
    console.log(path);
    console.log(newpath);
    console.log(originalFilename);
    var bin = Base64.atob(data);


    fs.writeFile(newpath, bin, "binary", function (err, writepath) {
        console.log("should we wait for the new file to be generated");

How to use js-base64.encodeURI:

1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
 * @param  {String} str - Origin string
 * @return {String}     - base64 value
 */
var getBase64 = toolkit.getBase64 = function getBase64(str, uriSafe) {
  if (uriSafe) {
    return Base64.encodeURI(str);
  } else {
    return Base64.encode(str);
  }
};

How to use js-base64.fromUint8Array:

327
328
329
330
331
332
333
334
335
336
  utf8: (value) => {
    return value.toString('utf8');
  },
  base64: (value) => {
    // `true` option makes it URL safe (replaces / and + with - and _ )
    return base64.fromUint8Array(value, true)
  }
};

/**

How to use js-base64.toUint8Array:

239
240
241
242
243
244
245
246
247
248
/**
* @param {string} value
* @return {Buffer}
*/
skynet: (value) => {
  return base64.toUint8Array(value)
},
/**
* @param {string} value
* @return {Buffer}

How to use js-base64.toBase64:

1
2
3
4
5
6
7
8
9
10
var toByteArray = require('base64-js').toByteArray;
var fromByteArray = require('base64-js').fromByteArray;
var jsBase64 = require('js-base64').Base64;
var base64Decode = jsBase64.decode;
var base64Encode = jsBase64.encode;
var toBase64 = jsBase64.toBase64;
var json2 = require('./components/json');
var events = require('./events');
var isUtf8 = require('./is-utf8');
var message = require('./message');

How to use js-base64.Base64:

114
115
116
117
118
119
120
121
122
123
    });
}
/* istanbul ignore next */
renderPdf(pdfBase64, renderFinished) {
    // @ts-ignore
    const loadingTask = (0, pdfjs_dist_1.getDocument)({ data: js_base64_1.Base64.atob(pdfBase64) });
    loadingTask.promise.then((pdf) => {
        // console.log('PDF loaded');
        this._totalPages = pdf.numPages;
        this._renderedPdf = pdf;

How to use js-base64.decode:

1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
 *
 * @param  {String} base64str  - base64 string
 * @return {String}            - Origin string
 */
var fromBase64 = toolkit.fromBase64 = function fromBase64(base64str) {
  return Base64.decode(base64str);
};


/**
 * Gzip string and return Base64 value.

How to use js-base64.encode:

1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
 */
var getBase64 = toolkit.getBase64 = function getBase64(str, uriSafe) {
  if (uriSafe) {
    return Base64.encodeURI(str);
  } else {
    return Base64.encode(str);
  }
};


/**