
Product
Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
@yosina-lib/yosina
Advanced tools
A TypeScript port of the Yosina Japanese text transliteration library.
Yosina is a library for Japanese text transliteration that provides various text normalization and conversion features commonly needed when processing Japanese text.
import { makeTransliterator, TransliterationRecipe } from '@yosina-lib/yosina';
// Create a recipe with desired transformations
const recipe: TransliterationRecipe = {
kanjiOldNew: true,
replaceSpaces: true,
replaceSuspiciousHyphensToProlongedSoundMarks: true,
replaceCircledOrSquaredCharacters: true,
replaceCombinedCharacters: true,
hiraKata: "hira-to-kata", // Convert hiragana to katakana
replaceJapaneseIterationMarks: true, // Expand iteration marks
toFullwidth: true,
};
// Create the transliterator
const transliterator = await makeTransliterator(recipe);
// Use it with various special characters
const input = '①②③ ⒶⒷⒸ ㍿㍑㌠㋿'; // circled numbers, letters, space, combined characters
const result = transliterator(input);
console.log(result); // "(1)(2)(3) (A)(B)(C) 株式会社リットルサンチーム令和"
// Convert old kanji to new
const oldKanji = '舊字體';
const kanjiResult = transliterator(oldKanji);
console.log(kanjiResult); // "旧字体"
// Convert half-width katakana to full-width
const halfWidth = 'テストモジレツ';
const fullWidthResult = transliterator(halfWidth);
console.log(fullWidthResult); // "テストモジレツ"
// Demonstrate hiragana to katakana conversion with iteration marks
const mixedText = '学問のすゝめ';
const convertedResult = transliterator(mixedText);
console.log(convertedResult); // "学問ノススメ"
import { makeTransliterator } from '@yosina-lib/yosina';
// Configure with direct transliterator configs
const configs = [
["kanji-old-new", {}],
["spaces", {}],
["prolonged-sound-marks", { replaceProlongedMarksFollowingAlnums: true }],
["circled-or-squared", {}],
["combined", {}],
["hira-kata", { mode: "kata-to-hira" }], // Convert katakana to hiragana
["japanese-iteration-marks", {}], // Expand iteration marks like 々, ゝゞ, ヽヾ
];
const transliterator = await makeTransliterator(configs);
// Example with various transformations including the new ones
const input = "カタカナでの時々の佐々木さん";
const result = transliterator(input);
console.log(result); // "かたかなでの時時の佐佐木さん"
circled-or-squared
)Converts circled or squared characters to their plain equivalents.
templates
(custom rendering), includeEmojis
(include emoji characters)①②③
→ (1)(2)(3)
, ㊙㊗
→ (秘)(祝)
combined
)Expands combined characters into their individual character sequences.
㍻
(Heisei era) → 平成
, ㈱
→ (株)
hira-kata-composition
)Combines decomposed hiraganas and katakanas into composed equivalents.
composeNonCombiningMarks
(compose non-combining marks)か + ゙
→ が
, ヘ + ゜
→ ペ
hira-kata
)Converts between hiragana and katakana scripts bidirectionally.
mode
("hira-to-kata" or "kata-to-hira")ひらがな
→ ヒラガナ
(hira-to-kata)hyphens
)Replaces various dash/hyphen symbols with common ones used in Japanese.
precedence
(mapping priority order)2019—2020
(em dash) → 2019-2020
ideographic-annotations
)Replaces ideographic annotations used in traditional Chinese-to-Japanese translation.
㆖㆘
→ 上下
ivs-svs-base
)Handles Ideographic and Standardized Variation Selectors.
charset
, mode
("ivs-or-svs" or "base"), preferSVS
, dropSelectorsAltogether
葛󠄀
(葛 + IVS) → 葛
japanese-iteration-marks
)Expands iteration marks by repeating the preceding character.
時々
→ 時時
, いすゞ
→ いすず
jisx0201-and-alike
)Handles half-width/full-width character conversion.
fullwidthToHalfwidth
, convertGL
(alphanumerics/symbols), convertGR
(katakana), u005cAsYenSign
ABC123
→ ABC123
, カタカナ
→ カタカナ
kanji-old-new
)Converts old-style kanji (旧字体) to modern forms (新字体).
舊字體の變換
→ 旧字体の変換
mathematical-alphanumerics
)Normalizes mathematical alphanumeric symbols to plain ASCII.
𝐀𝐁𝐂
(mathematical bold) → ABC
prolonged-sound-marks
)Handles contextual conversion between hyphens and prolonged sound marks.
skipAlreadyTransliteratedChars
, allowProlongedHatsuon
, allowProlongedSokuon
, replaceProlongedMarksFollowingAlnums
イ−ハト−ヴォ
(with hyphen) → イーハトーヴォ
(prolonged mark)radicals
)Converts CJK radical characters to their corresponding ideographs.
⾔⾨⾷
(Kangxi radicals) → 言門食
spaces
)Normalizes various Unicode space characters to standard ASCII space.
A B
(ideographic space) → A B
roman-numerals
)Converts Unicode Roman numeral characters to their ASCII letter equivalents.
Ⅰ Ⅱ Ⅲ
→ I II III
, ⅰ ⅱ ⅲ
→ i ii iii
npm install @yosina-lib/yosina
This project uses Node.js with TypeScript and Biome for formatting/linting.
# Install dependencies
npm install
# Run tests
npm test
# Run linting
npm run lint
# Run formatting
npm run format
# Build the library
npm run build
# Generate documentation
npm run docs:build
MIT
FAQs
Japanese text transliteration library for JavaScript/TypeScript
The npm package @yosina-lib/yosina receives a total of 162 weekly downloads. As such, @yosina-lib/yosina popularity was classified as not popular.
We found that @yosina-lib/yosina demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.