Code coverage report for lib/deps/binary/base64.js

Statements: 100% (14 / 14)      Branches: 100% (6 / 6)      Functions: 100% (4 / 4)      Lines: 100% (14 / 14)      Ignored: 4 statements, 2 functions, 2 branches     

All files » lib/deps/binary/ » base64.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33    2     2 1   1     2 1023     1023 4   1019         2 1   1     2 2394    
'use strict';
 
var buffer = require('./buffer');
 
/* istanbul ignore if */
Iif (typeof atob === 'function') {
  exports.atob = function (str) {
    /* global atob */
    return atob(str);
  };
} else {
  exports.atob = function (str) {
    var base64 = new buffer(str, 'base64');
    // Node.js will just skip the characters it can't encode instead of
    // throwing and exception
    if (base64.toString('base64') !== str) {
      throw ("Cannot base64 encode full string");
    }
    return base64.toString('binary');
  };
}
 
/* istanbul ignore if */
Iif (typeof btoa === 'function') {
  exports.btoa = function (str) {
    /* global btoa */
    return btoa(str);
  };
} else {
  exports.btoa = function (str) {
    return new buffer(str, 'binary').toString('base64');
  };
}