How to use strip-bom-stream - 3 common examples

To help you get started, we’ve selected a few strip-bom-stream examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github triplecanopy / b-ber / packages / b-ber-connect / google / download.es6 View on Github external
function exportFile(file, done) {
    console.log('-- downloading %s', file.name)
    const { id, name } = file
    const tmpFile = path.join(__dirname, '.drive', TMP_DIRNAME, name)
    const dest = fs.createWriteStream(tmpFile)

    const request = drive.files.export({ auth, fileId: id, mimeType: REQUEST_MIMETYPE })
        .pipe(stripBomStream())
        .pipe(dest)

    request.on('finish', () => {
        const fpath = path.join(path.dirname(tmpFile), name)
        // pass `content` to user-defined middleware in case further any
        // intermediate transforms need to take place. default is a simple pass-
        // through
        const content = transformWithMiddleware(fs.readFileSync(tmpFile, 'utf8')/*, contentType */)

        fs.writeFile(fpath, content, err => {
            done(err, file)
        })
    })

    request.on('error', done)
}
github mozilla / addons-linter / src / io / directory.js View on Github external
async getFileAsStream(relativeFilePath, { encoding } = { encoding: 'utf8' }) {
    const filePath = await this.getPath(relativeFilePath);

    const readStream = createReadStream(filePath, {
      autoClose: true,
      encoding,
      flags: 'r',
    });

    return !encoding ? readStream : readStream.pipe(stripBomStream());
  }
github mozilla / addons-linter / src / io / xpi.js View on Github external
zipfile.openReadStream(this.files[path], (err, readStream) => {
        if (err) {
          return reject(err);
        }
        return resolve(readStream.pipe(stripBomStream()));
      });
    });

strip-bom-stream

Strip UTF-8 byte order mark (BOM) from a stream

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular strip-bom-stream functions