npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kana-convert

v1.0.9

Published

A utility library for converting from [Kana](https://en.wikipedia.org/wiki/Kana) to [Rōmaji](https://en.wikipedia.org/wiki/Romanization_of_Japanese)

Downloads

3

Readme

kana-convert

A utility library for converting from Kana to Rōmaji

Punctuation are allowed and any Japanese punctuation will be converted to their Roman alphabet equivalent.

Examples

const { romanize } = require('../src/romanize');

romanize('かきくけこ')

// {
//   status:  'SUCCESS',
//   result: 'kakikukeko',
// }

romanize('hello')

// {
//   status:  'ERROR',
//   result: 'Error at h',
// }

Romanization config options

By default non-kana characters are not allowed, but nonKanaAllowed: true turns this off:

romanize('a) か b) き c) く', { nonKanaAllowed: false })

// {
//   status: 'ERROR',
//   result: 'Error at a',
// }

romanize('a) か b) き c) く', { nonKanaAllowed: true })

// {
//   status: 'SUCCESS',
//   result: 'a) ka b) ki c) ku',
// }

By default long vowels will be romanized by doubling vowels up corresponding exactly to the original kana, this can be turned off with mergeLongVowels: true. However, it is not always possible to distinguish between a long vowel and two separate short vowels in kana, so this will not always be perfect. For example, the kana "おう" could be rendered either as "ou" (as in 王) or as "ō" (as in 追う). Determining the correct romanization in such cases therefore requires more information than is actually encoded by the kana. If this option is turned on, all such sequences will be interpreted as long vowels.

romanize('がっこう', { mergeLongVowels: false })

// {
//   status: 'SUCCESS',
//   result: 'gakkou',
// }

romanize('がっこう', { mergeLongVowels: true })

// {
//   status: 'SUCCESS',
//   result: 'gakkō',
// }

By default, s + i/y, t + i/y and h + u are romanized as 'si', 'ti', 'sya', 'tya', 'hu', etc. This is more accurate to the phonology of Japanese. Some romanization systems anglicize these sounds to 'shi', 'chi', 'sha', 'cha', 'fu', etc., aligning them more closely with English phonology. This can be turned on with anglphone: true.

romanize('かいしゃ', { anglophone: false })

// {
//   status: 'SUCCESS',
//   result: 'kaisya',
// }

romanize('かいしゃ', { anglophone: true })

// {
//   status: 'SUCCESS',
//   result: 'kaisha',
// }

Multiple config options can be enabled at once, for example:

romanize('A: しょうがっこう', {
  mergeLongVowels: true,
  anglophone: true,
  nonKanaAllowed: true,
})

// {
//   status: 'SUCCESS',
//   result: 'A: shōgakkō',
// }

Installation

yarn or npm install (requires node and npm or yarn)

Tests

yarn test or npm run test

Linting

yarn lint or npm run lint