File tree 3 files changed +27
-20
lines changed
3 files changed +27
-20
lines changed Original file line number Diff line number Diff line change 32
32
$(ESLINT ) \
33
33
--config node_modules/sanctuary-style/eslint-es3.json \
34
34
--global $$ \
35
+ --global define \
35
36
--global exports \
37
+ --global module \
36
38
--global self \
37
39
--rule ' max-len: [off]' \
38
40
--rule ' no-plusplus: [off]' \
Original file line number Diff line number Diff line change 2
2
3
3
[ ![ CDNJS] ( https://img.shields.io/cdnjs/v/Base64.svg )] ( https://cdnjs.com/libraries/Base64 )
4
4
5
- ≈ 600 byte* polyfill for browsers which don't provide [ ` window.btoa ` ] [ 1 ] and
5
+ ≈ 700 byte* polyfill for browsers which don't provide [ ` window.btoa ` ] [ 1 ] and
6
6
[ ` window.atob ` ] [ 2 ] .
7
7
8
8
Base64.js stems from a [ gist] [ 3 ] by [ yahiko] [ 4 ] .
Original file line number Diff line number Diff line change 1
- ( function ( ) {
1
+ ( function ( f ) {
2
2
3
3
'use strict' ;
4
4
5
- var object = (
6
- // #34: CommonJS
7
- typeof exports === 'object' && exports != null &&
8
- typeof exports . nodeType !== 'number' ?
9
- exports :
10
- // #8: web workers
11
- typeof self !== 'undefined' ?
12
- self :
13
- // #31: ExtendScript
14
- $ . global
15
- ) ;
5
+ /* istanbul ignore else */
6
+ if ( typeof exports === 'object' && exports != null &&
7
+ typeof exports . nodeType !== 'number' ) {
8
+ module . exports = f ( ) ;
9
+ } else if ( typeof define === 'function' && define . amd != null ) {
10
+ define ( [ ] , f ) ;
11
+ } else {
12
+ var base64 = f ( ) ;
13
+ var global = typeof self !== 'undefined' ? self : $ . global ;
14
+ if ( typeof global . btoa !== 'function' ) global . btoa = base64 . btoa ;
15
+ if ( typeof global . atob !== 'function' ) global . atob = base64 . atob ;
16
+ }
17
+
18
+ } ( function ( ) {
19
+
20
+ 'use strict' ;
16
21
17
22
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' ;
18
23
24
29
25
30
// encoder
26
31
// [https://gist.github.com/999166] by [https://github.com/nignag]
27
- object . btoa || (
28
- object . btoa = function ( input ) {
32
+ function btoa ( input ) {
29
33
var str = String ( input ) ;
30
34
for (
31
35
// initialize result and counter
44
48
block = block << 8 | charCode ;
45
49
}
46
50
return output ;
47
- } ) ;
51
+ }
48
52
49
53
// decoder
50
54
// [https://gist.github.com/1020396] by [https://github.com/atk]
51
- object . atob || (
52
- object . atob = function ( input ) {
55
+ function atob ( input ) {
53
56
var str = ( String ( input ) ) . replace ( / [ = ] + $ / , '' ) ; // #31: ExtendScript bad parse of /=
54
57
if ( str . length % 4 === 1 ) {
55
58
throw new InvalidCharacterError ( "'atob' failed: The string to be decoded is not correctly encoded." ) ;
69
72
buffer = chars . indexOf ( buffer ) ;
70
73
}
71
74
return output ;
72
- } ) ;
75
+ }
76
+
77
+ return { btoa : btoa , atob : atob } ;
73
78
74
- } ( ) ) ;
79
+ } ) ) ;
You can’t perform that action at this time.
0 commit comments