File tree Expand file tree Collapse file tree 2 files changed +33
-14
lines changed Expand file tree Collapse file tree 2 files changed +33
-14
lines changed Original file line number Diff line number Diff line change 1
- ' use strict'
1
+ " use strict" ;
2
2
3
- const loaderUtils = require ( ' loader-utils' )
3
+ const loaderUtils = require ( " loader-utils" ) ;
4
4
5
5
module . exports = function ( content ) {
6
- if ( this . cacheable ) { this . cacheable ( ) }
6
+ if ( this . cacheable ) {
7
+ this . cacheable ( ) ;
8
+ }
7
9
10
+ const request = require . resolve ( "./to-array-buffer.js" ) ;
11
+
12
+ // loader-utils stringifyRequest was deprecated
8
13
const toArrayBufferPath =
9
- loaderUtils . stringifyRequest ( this , require . resolve ( './to-array-buffer.js' ) )
14
+ this . utils && this . utils . contextify
15
+ ? JSON . stringify (
16
+ this . utils . contextify ( this . context || this . rootContext , request )
17
+ )
18
+ : loaderUtils . stringifyRequest ( this , request ) ;
10
19
11
- const base64Data = content . toString ( ' base64' )
20
+ const base64Data = content . toString ( " base64" ) ;
12
21
13
22
return `module.exports = require(${ toArrayBufferPath } )("${ base64Data } ")` ;
14
- }
23
+ } ;
15
24
16
- module . exports . raw = true
25
+ module . exports . raw = true ;
Original file line number Diff line number Diff line change 1
- ' use strict'
1
+ " use strict" ;
2
2
3
3
module . exports = function ( base64Data ) {
4
- var isBrowser = typeof window !== 'undefined' && typeof window . atob === 'function'
5
- var binary = isBrowser ? window . atob ( base64Data ) : Buffer . from ( base64Data , 'base64' ) . toString ( 'binary' )
6
- var bytes = new Uint8Array ( binary . length )
4
+ var global =
5
+ typeof window !== "undefined"
6
+ ? window
7
+ : typeof self !== "undefined"
8
+ ? self
9
+ : undefined ;
10
+
11
+ var binary =
12
+ global && typeof global . atob === "function"
13
+ ? global . atob ( base64Data )
14
+ : Buffer . from ( base64Data , "base64" ) . toString ( "binary" ) ;
15
+
16
+ var bytes = new Uint8Array ( binary . length ) ;
7
17
8
18
for ( var i = 0 ; i < binary . length ; ++ i ) {
9
- bytes [ i ] = binary . charCodeAt ( i )
19
+ bytes [ i ] = binary . charCodeAt ( i ) ;
10
20
}
11
21
12
- return bytes . buffer
13
- }
22
+ return bytes . buffer ;
23
+ } ;
You can’t perform that action at this time.
0 commit comments