Socket
Socket
Sign inDemoInstall

md5-file

Package Overview
Dependencies
0
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.6 to 3.0.0

9

index.js

@@ -27,6 +27,4 @@ 'use strict'

module.exports = function (filename, cb) {
if (typeof cb !== 'function') {
return md5FileSync(filename)
}
function md5File (filename, cb) {
if (typeof cb !== 'function') throw new TypeError('Argument cb must be a function')

@@ -46,1 +44,4 @@ var output = crypto.createHash('md5')

}
module.exports = md5File
module.exports.sync = md5FileSync

@@ -11,3 +11,3 @@ {

],
"version": "2.0.6",
"version": "3.0.0",
"description": "return an md5sum of a given file",

@@ -14,0 +14,0 @@ "keywords": [

@@ -24,3 +24,3 @@ # md5-file [![Build Status](https://travis-ci.org/roryrjb/md5-file.svg?branch=master)](https://travis-ci.org/roryrjb/md5-file) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)

/* Sync usage */
const hash = md5File('LICENSE.md')
const hash = md5File.sync('LICENSE.md')
console.log(`The MD5 sum of LICENSE.md is: ${hash}`)

@@ -37,3 +37,3 @@ ```

### `md5File(filepath: string) => string`
### `md5File.sync(filepath: string) => string`

@@ -40,0 +40,0 @@ Synchronously get the MD5-sum of the file at `filepath`.

@@ -11,2 +11,4 @@ /* eslint-env mocha */

function noop () {}
describe('md5File', function () {

@@ -23,5 +25,3 @@ it('works asynchronously', function (done) {

it('works synchronously', function () {
var actual = md5File(filename)
assert.equal(actual, preCheckedSum)
assert.equal(md5File.sync(filename), preCheckedSum)
})

@@ -37,2 +37,25 @@

})
it('requires a callback', function () {
assert.throws(function () { md5File(filename) }, TypeError)
})
it('only accepts strings and buffers', function () {
var invalidValues = [
[],
{},
123,
null,
undefined
]
if (typeof Symbol !== 'undefined') {
invalidValues.push(Symbol('test'))
}
invalidValues.forEach(function (value) {
assert.throws(function () { md5File.sync(value) }, TypeError)
assert.throws(function () { md5File(value, noop) }, TypeError)
})
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc