I implemented the Readable stream in Typescript. Here's how :
import * as stream from 'stream';
export class Readable extends stream.Readable {
lastLineData = '';
objectMode = true;
ended = false
constructor() {
super({objectMode:true});
}
_read = () => {}
send = data => {
if (!this.ended) {
this.push(data)
}
}
errorAndCancel = err => {
if (!this.ended) {
this.emit('error', err)
this.push(null)
this.ended = true
}
}
end = () => {
if (!this.ended) {
this.push(null)
this.ended = true
}
}
}
On some machine (Gitlab CI with electronuserland/wine-02.18) or Windows Server machine with node.js v10 give me this error :
[08:11:38] typescript: C:/git/celliers/synchro-pos/src/providers/xmlStreamParser/Readable.ts, Class 'Readable' defines instance member function '_read', but extended class 'Readable' defines it as instance member property. L13: _read = () => {}
If I change _read to read, it doesn't work neither (same message). I question my implementation is not right. Is anyone able to tell me what I'm doing wrong?
Thanks!