File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change 11// Polyfill for btoa in Node.js
22/* global btoa */
3- function getBtoa ( ) {
4- if ( typeof btoa === "function" ) return btoa ;
5- return ( str ) => Buffer . from ( str , "binary" ) . toString ( "base64" ) ;
6- }
73
84module . exports = ( item ) => {
95 const [ , content , , cssMapping ] = item ;
@@ -12,8 +8,15 @@ module.exports = (item) => {
128 return content ;
139 }
1410
15- const btoaFn = getBtoa ( ) ;
16- const base64 = btoaFn (
11+ const btoaPolyfill =
12+ typeof btoa === "undefined"
13+ ? ( str ) => {
14+ const buffer =
15+ str instanceof Buffer ? str : Buffer . from ( str . toString ( ) , "binary" ) ;
16+ return buffer . toString ( "base64" ) ;
17+ }
18+ : btoa ;
19+ const base64 = btoaPolyfill (
1720 unescape ( encodeURIComponent ( JSON . stringify ( cssMapping ) ) ) ,
1821 ) ;
1922 const data = `sourceMappingURL=data:application/json;charset=utf-8;base64,${ base64 } ` ;
You can’t perform that action at this time.
0 commit comments