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 1.6.0 to 1.6.1

lib/utils.d.ts

4

lib/index.js

@@ -37,2 +37,3 @@ "use strict";

const iso2022 = __importStar(require("./encoding/iso2022"));
const utils_1 = require("./utils");
const recognisers = [

@@ -70,2 +71,5 @@ new utf8_1.default(),

const analyse = (buffer) => {
if (!(0, utils_1.isByteArray)(buffer)) {
throw new Error('Input must be a byte array, e.g. Buffer or Uint8Array');
}
const byteStats = [];

@@ -72,0 +76,0 @@ for (let i = 0; i < 256; i++)

4

package.json
{
"name": "chardet",
"version": "1.6.0",
"version": "1.6.1",
"homepage": "https://github.com/runk/node-chardet",

@@ -39,3 +39,3 @@ "description": "Character encoding detector",

"jest": "^29.0.0",
"prettier": "^2.7.1",
"prettier": "^3.0.0",
"semantic-release": "^21.0.0",

@@ -42,0 +42,0 @@ "ts-jest": "^29.0.0",

# chardet
*Chardet* is a character detection module written in pure JavaScript (TypeScript). Module uses occurrence analysis to determine the most probable encoding.
_Chardet_ is a character detection module written in pure JavaScript (TypeScript). Module uses occurrence analysis to determine the most probable encoding.

@@ -45,6 +45,13 @@ - Packed size is only **22 KB**

{ confidence: 90, name: 'UTF-8' },
{ confidence: 20, name: 'windows-1252', lang: 'fr' }
{ confidence: 20, name: 'windows-1252', lang: 'fr' },
];
```
In browser, you can use [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) instead of the `Buffer`:
```javascript
import chardet from 'chardet';
chardet.analyse(new Uint8Array([0x68, 0x65, 0x6c, 0x6c, 0x6f]));
```
## Working with large data sets

@@ -58,3 +65,3 @@

.detectFile('/path/to/file', { sampleSize: 32 })
.then(encoding => console.log(encoding));
.then((encoding) => console.log(encoding));
```

@@ -67,3 +74,3 @@

.detectFile('/path/to/file', { sampleSize: 32, offset: 128 })
.then(encoding => console.log(encoding));
.then((encoding) => console.log(encoding));
```

@@ -70,0 +77,0 @@

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