constreader=fs.createReadStream(absolutePath).pipe(encoding.decodeStream(fileEncoding));// decode takes care of stripping any BOMs from the file content
letcontent:files.IStreamContent=<any>model;
content.value=reader;
content.encoding=fileEncoding;// make sure to store the encoding in the model to restore it later when writing
constreader=fs.createReadStream(absolutePath).pipe(encoding.decodeStream(fileEncoding));// decode takes care of stripping any BOMs from the file content
letchunks:string[]=[];
reader.on('data',(buf)=>{
streamContent.value.on('data',(buf)=>{
chunks.push(buf);
});
reader.on('error',(error)=>{
streamContent.value.on('error',(error)=>{
if(!done){
done=true;
e(error);
}
});
reader.on('end',()=>{
letcontent:files.IContent=<any>model;
streamContent.value.on('end',()=>{
letcontent:files.IContent=<any>streamContent;
content.value=chunks.join('');
content.encoding=fileEncoding;// make sure to store the encoding in the model to restore it later when writing