This package has been deprecated

Author message:

The library has been renamed to @economia/checksum-promise

checksum-promise

1.0.3 • Public • Published

checksum-promise

Get checksum of a file in the browser using promises.

Basic usage

Complete documentation of the files can be found here.

First of all you need to include the Checksum class (either via ES6 imports or using CommonJS):

ES6

import Checksum from 'checksum-promise'

CommonJS

const Checksum = require('checksum-promise')

Then, all you need to do is instantiate the class (optionally passing in a config object):

const checksum = new Checksum()

Currently, the only option available in the config is the chunk size you want to divide your file by.

Optional config format:

{
  chunkSize: 10485760
}

10485760 is the default value of the chunk size, therefore if you are ok with using this size, you don't need to supply a config whatsoever.

Finally, you can call the calculateMd5 method of the initialized object:

checksum.calculateMd5(file).then(checksum => {
  // do whatever you need with the checksum
}).catch(error => {
  // in case calculating the checksum failed
})

The provided file should be retrieved from an event on a file input, like so:

function onFileInputChange (event) {
  const file = event.target.files[0]
}

Contributing

In case you want to contribute to this library, create a pull request on our BitBucket, stating what you changed.

Readme

Keywords

none

Package Sidebar

Install

npm i checksum-promise

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

1.57 MB

Total Files

35

Last publish

Collaborators

  • ecodevs