function ascCompile(source) {
const output = Object.create({
stdout: asc.createMemoryStream(),
stderr: asc.createMemoryStream()
});
asc.main(
["input.ts", "-O3", "--binaryFile", "binary", "--textFile", "text"],
{
stdout: output.stdout,
stderr: output.stderr,
readFile: name => (name === "input.ts" ? source : null),
writeFile: (name, contents) => {
output[name] = contents;
},
listFiles: () => []
},
err => {
if (err) throw new Error(output.stderr.toString());
}
);
return output;
}