You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

char-encoding-detector

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

char-encoding-detector - npm Package Compare versions

Comparing version

to
0.0.8

25

dist/index.d.ts
import { Options, IMatch } from './type';
/**
* Returns the most probable encoding or the list matching encoding ordered by confidence if { allMatches: true }
* is set in opts parameter.
*/
export declare function detectEncoding(buffer: Uint8Array, opts?: Options): IMatch[] | string;
/**
* Returns the character encoding with the highest confidence
*/
export declare function detectMostProbableEncoding(buffer: Uint8Array): string;
/**
* Returns an array of possible character encodings ordered by confidence.
*/
export declare function detectAllPossibleEncodings(buffer: Uint8Array): IMatch[];
/**
* Reads the file and returns the character encoding with the highest confidence or
* array of possible character encodings ordered by confidence if { allMatches: true }
* is set in opts parameter.
*/
export declare function detectFileEncoding(file: File, opts?: Options): Promise<string | IMatch[]>;
/**
* Reads the file and returns the character encoding with the highest confidence.
*/
export declare function detectFileMostProbableEncoding(file: File): Promise<string>;
/**
* Reads the file and returns array of possible character encodings ordered by confidence.
*/
export declare function detectFileAllPossibleEncodings(file: File): Promise<IMatch[]>;

2

package.json
{
"name": "char-encoding-detector",
"version": "0.0.7",
"version": "0.0.8",
"homepage": "https://github.com/GlobalSport/char-encoding-detector",

@@ -5,0 +5,0 @@ "description": "Character encoding detector",

@@ -5,3 +5,6 @@ ![travis static](https://travis-ci.com/GlobalSport/js-chardet.svg?branch=master)

Port of [node-chardet](https://github.com/runk/node-chardet) in pure JavaScript without NodeJS specific code.
Port of [node-chardet](https://github.com/runk/node-chardet) in pure JavaScript without NodeJS specific API, ie. it can be used in browser.
=====
Module is based on ICU project http://site.icu-project.org/, which uses character

@@ -25,6 +28,8 @@ occurrence analysis to determine the most probable encoding.

```javascript
import { detectEncoding, detectFileEncoding } from 'char-encoding-detector';
detectEncoding(uint8Array);
import { detectMostProbableEncoding, detectFileMostProbableEncoding } from 'char-encoding-detector';
const encoding = detectMostProbableEncoding(uint8Array);
// or
detectFileEncoding(file).then((encoding) => {});
detectFileMostProbableEncoding(file).then((encodings) => {});
```

@@ -35,7 +40,9 @@

```javascript
import { detectEncoding, detectFileEncoding } from 'char-encoding-detector';
import { detectAllPossibleEncodings, detectFileAllPossibleEncodings } from 'char-encoding-detector';
detectEncoding(uint8Array, { allMatches: true });
const encodings = detectAllPossibleEncodings(uint8Array);
// or
detectFileEncoding(file, { allMatches: true });
detectFileAllPossibleEncodings(file).then((encodings) => {});
```

@@ -42,0 +49,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet