fix: update import paths

This commit is contained in:
Derrick Hammer 2023-07-12 04:34:15 -04:00
parent 6e492286b4
commit cb5f404817
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
9 changed files with 35 additions and 29 deletions

View File

@ -1,5 +1,5 @@
import { Context, Recogniser } from '.';
import match, { Match } from '../match';
import { Context, Recogniser } from './index.js';
import match, { Match } from '../match.js';
export default class Ascii implements Recogniser {
name() {

View File

@ -1,4 +1,4 @@
import { Match } from '../match';
import { Match } from '../match.js';
export interface Recogniser {
match(input: Context): Match | null;

View File

@ -1,5 +1,5 @@
import { Context, Recogniser } from '.';
import match, { Match } from '../match';
import { Context, Recogniser } from './index.js';
import match, { Match } from '../match.js';
/**
* This is a superclass for the individual detectors for

View File

@ -1,5 +1,5 @@
import { Context, Recogniser } from '.';
import match, { Match } from '../match';
import { Context, Recogniser } from './index.js';
import match, { Match } from '../match.js';
/**
* Binary search implementation (recursive)

View File

@ -1,5 +1,5 @@
import { Context, Recogniser } from '../encoding/index';
import match, { Match } from '../match';
import { Context, Recogniser } from '../encoding/index.js';
import match, { Match } from '../match.js';
/**
* This class recognizes single-byte encodings. Because the encoding scheme is so

View File

@ -1,5 +1,5 @@
import { Context, Recogniser } from '.';
import match, { Match } from '../match';
import { Context, Recogniser } from './index.js';
import match, { Match } from '../match.js';
/**
* This class matches UTF-16 and UTF-32, both big- and little-endian. The

View File

@ -1,5 +1,5 @@
import { Context, Recogniser } from '.';
import match, { Match } from '../match';
import { Context, Recogniser } from './index.js';
import match, { Match } from '../match.js';
export default class Utf8 implements Recogniser {
name() {

View File

@ -1,21 +1,21 @@
import { Match } from './match';
import { Recogniser, Context } from './encoding';
import { Match } from './match.js';
import { Recogniser, Context } from './encoding/index.js';
import loadFs from './fs/node';
import loadFs from './fs/node.js';
import Ascii from './encoding/ascii';
import Utf8 from './encoding/utf8';
import * as unicode from './encoding/unicode';
import * as mbcs from './encoding/mbcs';
import * as sbcs from './encoding/sbcs';
import * as iso2022 from './encoding/iso2022';
import Ascii from './encoding/ascii.js';
import Utf8 from './encoding/utf8.js';
import * as unicode from './encoding/unicode.js';
import * as mbcs from './encoding/mbcs.js';
import * as sbcs from './encoding/sbcs.js';
import * as iso2022 from './encoding/iso2022.js';
interface FullOptions {
sampleSize: number,
offset: number
sampleSize: number;
offset: number;
}
export type Options = Partial<FullOptions>
export type Options = Partial<FullOptions>;
const recognisers: Recogniser[] = [
new Utf8(),
@ -88,9 +88,12 @@ export const analyse = (buffer: Uint8Array): AnalyseResult => {
});
return matches as Match[];
}
};
export const detectFile = (filepath: string, opts: Options = {}): Promise<DetectResult> =>
export const detectFile = (
filepath: string,
opts: Options = {}
): Promise<DetectResult> =>
new Promise((resolve, reject) => {
let fd: any;
const fs = loadFs();
@ -120,7 +123,10 @@ export const detectFile = (filepath: string, opts: Options = {}): Promise<Detect
fs.readFile(filepath, handler);
});
export const detectFileSync = (filepath: string, opts: Options = {}): DetectResult => {
export const detectFileSync = (
filepath: string,
opts: Options = {}
): DetectResult => {
const fs = loadFs();
if (opts && opts.sampleSize) {

View File

@ -1,4 +1,4 @@
import { Context, Recogniser } from "./encoding";
import { Context, Recogniser } from './encoding/index.js';
export interface Match {
confidence: number;