Nightly Perpetrated Mischief
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    checksum-streampublic

    checksum-stream npm version license Travis AppVeyor Coverage Status

    checksum-stream is a passthrough stream that calculates the digest and size for data piped through it. Before closing, it will emit digest and size events with the final stream size.

    It can also be configured to error if digest or size do not matched a passed-in value that is expected for either or both. size errors will always be emitted first.

    Install

    $ npm install --save checksum-stream

    Example

    npm repo

    const checksumStream = require('checksum-stream')
    const fs = require('fs')
    const request = require('request')
     
    let req = request.get('https://npm.im/checksum-stream')
    req.on('response', function (res) {
      res.pipe(
        checksumStream({
          algorithm: 'sha256',
          digest: res.headers['etag'],
          size: res.headers['content-length']
        }).on('error', e => throw e)
      ).pipe(
        fs.createWriteStream('./checksum-stream.html')
      )
    })

    install

    npm i checksum-stream

    Downloadsweekly downloads

    180

    version

    1.0.3

    license

    CC0-1.0

    repository

    github.com

    last publish

    collaborators

    • avatar