Fix atob under CommonJS module bundlers (eg. Browserify)
Browserify uses the browser version of the module but since module.exports was not assigned, importing it fails. * Fix a typo in the browser implementation of 'browser-atob' * Fix reference to the source file in the tests * Export 'atob' implementation in 'browser-atob.js' via module exports
Este cometimento está contido em:
ascendente
f6c7618c46
cometimento
50cb9f059a
@ -6,7 +6,7 @@
|
|||||||
function atob(str) {
|
function atob(str) {
|
||||||
// normal window
|
// normal window
|
||||||
if ('function' === typeof a2b) {
|
if ('function' === typeof a2b) {
|
||||||
return a2b(a2b);
|
return a2b(str);
|
||||||
}
|
}
|
||||||
// browserify (web worker)
|
// browserify (web worker)
|
||||||
else if ('function' === typeof Buffer) {
|
else if ('function' === typeof Buffer) {
|
||||||
@ -29,4 +29,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.atob = atob;
|
w.atob = atob;
|
||||||
|
|
||||||
|
if (typeof module !== 'undefined') {
|
||||||
|
module.exports = atob;
|
||||||
|
}
|
||||||
}(window));
|
}(window));
|
||||||
|
2
test.js
2
test.js
@ -2,7 +2,7 @@
|
|||||||
(function () {
|
(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var atob = require('./index')
|
var atob = require('.')
|
||||||
, encoded = "SGVsbG8gV29ybGQ="
|
, encoded = "SGVsbG8gV29ybGQ="
|
||||||
, unencoded = "Hello World"
|
, unencoded = "Hello World"
|
||||||
/*
|
/*
|
||||||
|
Carregando…
x
Criar uma nova questão referindo esta
Bloquear um utilizador