Skip to content
Merged
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ _and_ return the mapping from positions in the output string to the input string
(using regular character indexing, not fancy codepoint indexing since the APIs
we want to use these results with don't know about about surrogate pairs).

## `katakanaToHiragana`
## `kanaToHiragana`

Converts full-width katakana characters to hiragana. It doesn't handle
half-width katakana so you should run the input through `toNormalized` first if
Expand All @@ -32,10 +32,10 @@ Note that the length of the output is equal to the length of the input so this
function does not returning the mapping from input string character offsets to
output string positions.

## `hiraganaToKatakana`
## `kanaToKatakana`

Converts hiragana characters to full-width katakana. As with
`katakanaToHiragana` the length of the input and output is equal so this
`kanaToHiragana` the length of the input and output is equal so this
function does not return the mapping between character offsets.

## `kyuujitaiToShinjitai`
Expand Down
18 changes: 0 additions & 18 deletions src/hiragana-to-katakana.test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { expandChoon } from './expand-choon.js';
export { hiraganaToKatakana } from './hiragana-to-katakana.js';
export { kanaToKatakana } from './kana-to-katakana.js';
export { kanaToHiragana } from './kana-to-hiragana.js';
export { kyuujitaiToShinjitai } from './kyuujitai.js';
export { halfToFullWidthNum } from './numbers.js';
Expand Down
18 changes: 18 additions & 0 deletions src/kana-to-katakana.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { describe, expect, it } from 'vitest';

import { kanaToKatakana } from './kana-to-katakana.js';

describe('kanaToKatakana', () => {
it('converts hiragana', () => {
expect(kanaToKatakana('がーでん')).toEqual('ガーデン');
expect(kanaToKatakana('ゔゕゖ')).toEqual('ヴヵヶ');
});

it('converts iteration marks', () => {
expect(kanaToKatakana('ゝゞ')).toEqual('ヽヾ');
});

it("does not convert hiragana which don't have katakana equivalents", () => {
expect(kanaToKatakana('ゟ・ーか')).toEqual('ゟ・ーカ');
});
});
2 changes: 1 addition & 1 deletion src/hiragana-to-katakana.ts → src/kana-to-katakana.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function hiraganaToKatakana(input: string): string {
export function kanaToKatakana(input: string): string {
let result = '';

for (const char of input) {
Expand Down