What is strip-bom-stream?
The strip-bom-stream npm package is used to remove Byte Order Marks (BOM) from streams. BOMs are special markers at the start of text streams that indicate the encoding used. This package is particularly useful when dealing with text streams that may contain BOMs, ensuring that the BOM is stripped out so that the text can be processed correctly.
Remove BOM from a stream
This feature allows you to remove the BOM from a readable stream and pipe the cleaned data into a writable stream. In this example, the BOM is removed from 'file-with-bom.txt' and the result is written to 'file-without-bom.txt'.
const fs = require('fs');
const stripBomStream = require('strip-bom-stream');
fs.createReadStream('file-with-bom.txt')
.pipe(stripBomStream())
.pipe(fs.createWriteStream('file-without-bom.txt'));