chardet
Advanced tools
Comparing version 1.6.0 to 1.6.1
@@ -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++) |
{ | ||
"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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
158972
39
1837
115
1