Last change
on this file since 6fe77af was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | (function (w) {
|
---|
2 | "use strict";
|
---|
3 |
|
---|
4 | function findBest(atobNative) {
|
---|
5 | // normal window
|
---|
6 | if ('function' === typeof atobNative) { return atobNative; }
|
---|
7 |
|
---|
8 |
|
---|
9 | // browserify (web worker)
|
---|
10 | if ('function' === typeof Buffer) {
|
---|
11 | return function atobBrowserify(a) {
|
---|
12 | //!! Deliberately using an API that's deprecated in node.js because
|
---|
13 | //!! this file is for browsers and we expect them to cope with it.
|
---|
14 | //!! Discussion: github.com/node-browser-compat/atob/pull/9
|
---|
15 | return new Buffer(a, 'base64').toString('binary');
|
---|
16 | };
|
---|
17 | }
|
---|
18 |
|
---|
19 | // ios web worker with base64js
|
---|
20 | if ('object' === typeof w.base64js) {
|
---|
21 | // bufferToBinaryString
|
---|
22 | // https://git.coolaj86.com/coolaj86/unibabel.js/blob/master/index.js#L50
|
---|
23 | return function atobWebWorker_iOS(a) {
|
---|
24 | var buf = w.base64js.b64ToByteArray(a);
|
---|
25 | return Array.prototype.map.call(buf, function (ch) {
|
---|
26 | return String.fromCharCode(ch);
|
---|
27 | }).join('');
|
---|
28 | };
|
---|
29 | }
|
---|
30 |
|
---|
31 | return function () {
|
---|
32 | // ios web worker without base64js
|
---|
33 | throw new Error("You're probably in an old browser or an iOS webworker." +
|
---|
34 | " It might help to include beatgammit's base64-js.");
|
---|
35 | };
|
---|
36 | }
|
---|
37 |
|
---|
38 | var atobBest = findBest(w.atob);
|
---|
39 | w.atob = atobBest;
|
---|
40 |
|
---|
41 | if ((typeof module === 'object') && module && module.exports) {
|
---|
42 | module.exports = atobBest;
|
---|
43 | }
|
---|
44 | }(window));
|
---|
Note:
See
TracBrowser
for help on using the repository browser.