Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add types #93

Open
wants to merge 18 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,6 @@
"lint-staged": {
"src/**/*.js": "eslint",
"test/**/*.js": "eslint"
}
},
"types": "./src/index.d.ts"
}
38 changes: 38 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// to avoid mistakenly treating d.ts as js by ESLint.
/* eslint-disable */
declare class Kuroshiro {
constructor();
init(_analyzer: any): Promise<void>;
convert(
str: string,
options?: {
to?: string;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
to?: string;
to?: 'hiragana' | 'katakana' | 'romaji';

mode?: string;
romajiSystem?: string;
Comment on lines +10 to +11

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mode?: string;
romajiSystem?: string;
mode?: 'normal' | 'spaced' | 'okurigana' | 'furigana';
romajiSystem?: 'nippon' | 'passport' | 'hepburn';

delimiter_start?: string;
delimiter_end?: string;
}
): Promise<string>;
Util: {
isHiragana: (ch: string) => boolean;
isKatakana: (ch: string) => boolean;
isKana: (ch: string) => boolean;
isKanji: (ch: string) => boolean;
isJapanese: (ch: string) => boolean;
hasHiragana: (str: string) => boolean;
hasKatakana: (str: string) => boolean;
hasKana: (str: string) => boolean;
hasKanji: (str: string) => boolean;
hasJapanese: (str: string) => boolean;
kanaToHiragana: (str: string) => string;
kanaToKatakana: (str: string) => string;
kanaToRomaji: (
str: string,
system: "nippon" | "passport" | "hepburn"
) => string;
};
}

declare module "kuroshiro" {
export = Kuroshiro;
}