forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
28 lines (22 loc) · 637 Bytes
/
index.ts
File metadata and controls
28 lines (22 loc) · 637 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import Transpiler, { TranspilerResult } from '..';
class Base64Transpiler extends Transpiler {
constructor() {
super('base64-loader');
}
doTranspilation(code: string) {
return new Promise<TranspilerResult>(resolve => {
const reader = new FileReader();
// @ts-ignore
reader.readAsDataURL(code);
reader.onloadend = function() {
const base64data = reader.result;
resolve({
transpiledCode: `module.exports = "${base64data.toString()}"`,
});
};
});
}
}
const transpiler = new Base64Transpiler();
export { Base64Transpiler };
export default transpiler;