Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

md5-file

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

md5-file - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

40

index.js

@@ -1,27 +0,5 @@

// The MIT License (MIT)
//
// Copyright (c) 2014 Rory J. Bradford.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the 'Software'),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
'use strict';
var crypto = require('crypto'),
fs = require('fs');
var crypto = require('crypto');
var fs = require('fs');

@@ -32,3 +10,3 @@ module.exports = function (filename) {

return sum.digest('hex');
}
};

@@ -41,11 +19,9 @@ // if `strict` then throw error otherwise pass error through

throw error;
} else {
return callback(error);
}
} else {
var sum = crypto.createHash('md5');
sum.update(data);
return callback(sum.digest('hex'));
return callback(error);
}
var sum = crypto.createHash('md5');
sum.update(data);
return callback(sum.digest('hex'));
});
}
};

13

package.json
{
"name": "md5-file",
"main": "index.js",
"files" : [
"index.js", "test.js"
"files": [
"index.js",
"test.js"
],
"version": "1.1.2",
"version": "1.1.3",
"description": "return an md5sum of a given file",

@@ -28,5 +29,5 @@ "keywords": [

},
"scripts" : {
"test" : "node test"
"scripts": {
"test": "node test"
}
}
}

@@ -15,18 +15,26 @@ # md5-file

### Sync
### API
_Sync:_
__md5file(path)__
```javascript
var md5 = require('md5-file');
var md5file = require('md5-file');
md5('path/to/a_file'); // '18e904aae79b5642ed7975c0a0074936'
md5file('path/to/a_file'); // '18e904aae79b5642ed7975c0a0074936'
```
### Async
_Async:_
__md5file(path, callback, [strict])__
If _strict_ is `true` and there is an error it will `throw` it, otherwise it will pass an error string through the callback.
```javascript
md5.async('./README.md', function (data) {
md5file.async('./README.md', function (data) {
console.log(data);
});
md5.async('./README.md', function (data) {
md5file.async('./README.md', function (data) {
console.log(data);

@@ -38,3 +46,3 @@ }, true);

// non-strict: will pass through an error to `data`
md5.async('./null', function (data) {
md5file.async('./null', function (data) {
console.log(data);

@@ -44,3 +52,3 @@ });

// strict: will throw an error
md5.async('./null', function (data) {
md5file.async('./null', function (data) {
console.log(data);

@@ -47,0 +55,0 @@ }, true);

@@ -0,1 +1,3 @@

'use strict';
var md5 = require('./index');

@@ -2,0 +4,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc