lib/changed.js
async function compareStream (filename, expectedContents) {
  try {
    const actualStream = fs.createReadStream(filename)
    const result = await streamCompare(expectedContents, actualStream, {
      abortOnError: true,
      compare: (a, b) => {
        return Buffer.compare(a.data, b.data) !== 0
      }
    })
    return result
  } catch (err) {
    return handleError(err)
  }
}
async function compareStream (filename, expectedContents) {
  try {
    const actualStream = fs.createReadStream(filename)
    const result = await streamCompare(expectedContents, actualStream, {
      abortOnError: true,
      compare: (a, b) => {
        return Buffer.compare(a.data, b.data) !== 0
      }
    })
    return result
  } catch (err) {
    return handleError(err)
  }
}
async function compareStream ( filename , expectedContents ) { try { const actualStream = fs . createReadStream ( filename ) const result = await streamCompare ( expectedContents , actualStream , { abortOnError : true , compare : ( a , b ) => { return Buffer . compare ( a . data , b . data ) !== 0 } } ) return result } catch ( err ) { return handleError ( err ) } }
Compares a readable stream with a file contents. Returns true, if they differ or the file does not exist.
@param {string} filename the file name
@param {Stream} expectedContents the file contents
@returns {Promise<boolean>|boolean}
@private
Compares a readable stream with a file contents . Returns true if they differ or the file does not exist .