Skip to content

Commit

Permalink
dev: add d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
keroxp committed Nov 18, 2024
1 parent 0c6f209 commit 3ecbb2e
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 2 deletions.
52 changes: 52 additions & 0 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
declare module "@loilo-inc/eld" {
class LanguageResult {
language: string;
getScores(): Record<string, number>;
isReliable(): boolean;
}
interface EldInfo {
"Data type": string;
Languages: string[];
"Dynamic subset": boolean | Record<string, number>;
}
interface Eld {
detect(text: string): LanguageResult;
cleanText(clean: boolean): void;
dynamicLanguSubset(
languages: Record<string, number>
): Record<string, number>;
saveSubset(languages: Record<string, number>): void;
info(): EldInfo;
}
interface EldWithNgramLoador extends Eld {
loadNgrams(
file: "ngramL60.js" | "ngramM60.js" | "ngramS60.js" | "ngramXS60.js"
): Promise<void>;
}
export const eld: EldWithNgramLoador;
}

declare module "@loilo-inc/eld/src/entries/static.M60.js" {
import { Eld } from "@loilo-inc/eld";
export const eld: Eld;
}

declare module "@loilo-inc/eld/src/entries/static.L60.js" {
import { Eld } from "@loilo-inc/eld";
export const eld: Eld;
}

declare module "@loilo-inc/eld/src/entries/static.M60.js" {
import { Eld } from "@loilo-inc/eld";
export const eld: Eld;
}

declare module "@loilo-inc/eld/src/entries/static.S60.js" {
import { Eld } from "@loilo-inc/eld";
export const eld: Eld;
}

declare module "@loilo-inc/eld/src/entries/static.XS60.js" {
import { Eld } from "@loilo-inc/eld";
export const eld: Eld;
}
33 changes: 31 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,41 @@
{
"name": "eld",
"name": "@loilo-inc/eld",
"version": "1.0.1",
"description": "Fast and accurate natural language detection. Detector written in Javascript. Efficient language detector, Nito-ELD, ELD.",
"main": "src/entries/dynamic.js",
"type": "module",
"types": "@types/index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/nitotm/efficient-language-detector-js.git"
"url": "git+https://github.com/loilo-inc/efficient-language-detector-js.git"
},
"files": [
"src",
"@types",
"LICENSE",
"README.md"
],
"exports": {
".": {
"import": "./src/entries/dynamic.js",
"types": "./@types/index.d.ts"
},
"./src/entries/static.L60.js": {
"import": "./src/entries/static.L60.js",
"types": "./@types/index.d.ts"
},
"./src/entries/static.M60.js": {
"import": "./src/entries/static.M60.js",
"types": "./@types/index.d.ts"
},
"./src/entries/static.S60.js": {
"import": "./src/entries/static.S60.js",
"types": "./@types/index.d.ts"
},
"./src/entries/static.XS60.js": {
"import": "./src/entries/static.XS60.js",
"types": "./@types/index.d.ts"
}
},
"keywords": [
"nlp",
Expand Down

0 comments on commit 3ecbb2e

Please sign in to comment.