Нема описа

browser-atob.js 931B

123456789101112131415161718192021222324252627282930313233343536
  1. (function (w) {
  2. "use strict";
  3. var a2b = w.atob;
  4. function atob(str) {
  5. // normal window
  6. if ('function' === typeof a2b) {
  7. return a2b(str);
  8. }
  9. // browserify (web worker)
  10. else if ('function' === typeof Buffer) {
  11. return new Buffer(str, 'base64').toString('binary');
  12. }
  13. // ios web worker with base64js
  14. else if ('object' === typeof w.base64js) {
  15. // bufferToBinaryString
  16. // https://github.com/coolaj86/unibabel-js/blob/master/index.js#L50
  17. var buf = w.base64js.b64ToByteArray(str);
  18. return Array.prototype.map.call(buf, function (ch) {
  19. return String.fromCharCode(ch);
  20. }).join('');
  21. }
  22. // ios web worker without base64js
  23. else {
  24. throw new Error("you're probably in an ios webworker. please include use beatgammit's base64-js");
  25. }
  26. }
  27. w.atob = atob;
  28. if (typeof module !== 'undefined') {
  29. module.exports = atob;
  30. }
  31. }(window));