feat: renderFileToNodeStream(filepath, scope)

This commit is contained in:
harttle
2021-10-03 21:21:25 +08:00
parent dd325362f9
commit 68c4cfcfb6
7 changed files with 107 additions and 4 deletions
+6 -2
View File
@@ -1,11 +1,15 @@
import { stringify } from '../util/underscore'
import { Emitter } from './emitter'
export class StreamedEmitter {
export class StreamedEmitter implements Emitter {
public buffer = '';
public stream = new (require('stream').PassThrough)()
public stream: NodeJS.ReadWriteStream = new (require('stream').PassThrough)()
public write (html: any) {
this.stream.write(stringify(html))
}
public error (err: Error) {
this.stream.emit('error', err)
}
public end () {
this.stream.end()
}