maketypes
Version:
Make TypeScript types and proxy objects from example JSON objects. Can use proxy objects to dynamically type check JSON at runtime.
21 lines (19 loc) • 452 B
text/typescript
import Writer from './writer';
/**
* Writes output to a stream.
*/
export default class StreamWriter extends Writer {
public readonly stream: NodeJS.WritableStream;
constructor(stream: NodeJS.WritableStream) {
super();
this.stream = stream;
}
public write(s: string): this {
this.stream.write(new Buffer(s, 'utf8'));
return this;
}
public close(cb: () => void): void {
this.stream.end();
setTimeout(cb, 4);
}
}