perf: make the most of streamed rendering

This commit is contained in:
Harttle
2021-10-01 18:36:57 +08:00
committed by harttle
parent 4358c9630f
commit aea34418de
13 changed files with 65 additions and 71 deletions
+2 -2
View File
@@ -10,7 +10,7 @@ import { KeepingTypeEmitter } from '../emitters/keeping-type-emitter'
export class Render {
public renderTemplatesToNodeStream (templates: Template[], ctx: Context): NodeJS.ReadableStream {
const emitter = new StreamedEmitter()
toThenable(this.renderTemplates(templates, ctx, emitter))
toThenable(this.renderTemplates(templates, ctx, emitter)).then(() => emitter.end())
return emitter.stream
}
public * renderTemplates (templates: Template[], ctx: Context, emitter?: Emitter): IterableIterator<any> {
@@ -29,6 +29,6 @@ export class Render {
throw err
}
}
return emitter.end()
return emitter.buffer
}
}