Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

chardet

Package Overview
Dependencies
0
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.2 to 0.5.0

21

index.js

@@ -38,3 +38,3 @@

module.exports.detect = function(buffer) {
module.exports.detect = function(buffer, opts) {

@@ -66,3 +66,3 @@ // Tally up the byte occurence statistics.

var match = recognisers.map(function(rec) {
var matches = recognisers.map(function(rec) {
return rec.match(context);

@@ -72,6 +72,11 @@ }).filter(function(match) {

}).sort(function(a, b) {
return a.confidence - b.confidence;
}).pop();
return b.confidence - a.confidence;
});
return match ? match.name : null;
if (opts && opts.returnAllMatches === true) {
return matches;
}
else {
return matches.length > 0 ? matches[0].name : null;
}
};

@@ -93,3 +98,3 @@

if (err) return cb(err, null);
cb(null, self.detect(buffer));
cb(null, self.detect(buffer, opts));
};

@@ -117,6 +122,6 @@

fs.closeSync(fd);
return self.detect(sample);
return self.detect(sample, opts);
}
return self.detect(fs.readFileSync(filepath));
return self.detect(fs.readFileSync(filepath), opts);
};
{
"name": "chardet",
"version": "0.4.2",
"version": "0.5.0",
"homepage": "https://github.com/runk/node-chardet",

@@ -16,7 +16,11 @@ "description": "Character detector",

"contributors": [
"@spikying"
"@spikying",
"@wtgtybhertgeghgtwtg",
"@suisho",
"@seangarner",
"@zevanty"
],
"devDependencies": {
"github-publish-release": "^4.0.0",
"mocha": "^4.0.1"
"github-publish-release": "^4.2.0",
"mocha": "^5.1.1"
},

@@ -32,3 +36,3 @@ "repository": {

"scripts": {
"test": "mocha -R spec --recursive",
"test": "mocha -R spec --recursive --bail",
"release": "scripts/release"

@@ -35,0 +39,0 @@ },

@@ -35,2 +35,12 @@

## Returning more detailed results
If you wish to see the full list of possible encodings:
```javascript
chardet.detectFile('/path/to/file', { returnAllMatches: true }, function(err, encodings) {
//encodings is an array of objects sorted by confidence value in decending order
//e.g. [{ confidence: 90, name: 'UTF-8'}, {confidence: 20, name: 'windows-1252', lang: 'fr'}]
});
```
## Supported Encodings:

@@ -37,0 +47,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc