lipilekhika
v1.0.4
Published
A transliteration library for Indian Brahmic scripts
Maintainers
Readme
Lipi Lekhika — JavaScript/TypeScript
A powerful, typesafe transliteration library for Indian Brahmic scripts with real-time typing support
📖 Documentation • 🌐 Website • 📝 Changelog
✨ Features
- 🔄 Bidirectional Transliteration — Convert between 15+ Indian Brahmic scripts
- 🛡️ Full TypeScript Support — Type-safe script/language names and options
- 📦 Multiple Module Formats — Tree-shakable ESM, CommonJS, and UMD builds
- ⚡ Real-time Typing — Low-latency typing engine for browser environments
- 🚀 WASM Support - Use Blazing fast Rust 🦀 in JS environments
- 🎯 Highly Customizable — Fine-tune transliteration with custom options
- 🌍 Universal Runtime — Works in Node.js, browsers, Deno, Bun, and more
- 🪶 Lightweight — Only 7 KB gzipped
📥 Installation
npm install lipilekhikapnpm add lipilekhika
bun add lipilekhika
yarn add lipilekhika🚀 Quick Start
Basic Transliteration
import { transliterate } from 'lipilekhika';
// Transliterate from Normal script to Devanagari
const result = await transliterate('na jAyatE mriyatE vA', 'Normal', 'Devanagari');
console.log(result); // न जायते म्रियते वाWith Custom Options
import { transliterate } from 'lipilekhika';
const result = await transliterate(
'గంగా',
'Devanagari',
'Gujarati',
{ 'brahmic_to_brahmic:replace_pancham_varga_varna_with_anusvAra': true }
);
console.log(result); // ગંગા (instead of ગઙ્ગા)📖 See all Custom Transliteration Options
📚 Core API
Functions
Parameters:
text: string— Text to transliteratefrom: ScriptLangType— Source script/languageto: ScriptLangType— Target script/languageoptions?: TransliterationOptions— Custom transliteration options
Returns: Promise<string>
Parameters:
name: ScriptLangType— Script/language name to preload
Returns: Promise<ScriptData>
Note: Useful in browsers to avoid initial loading delay.
Parameters:
from: ScriptLangType— Source script/languageto: ScriptLangType— Target script/language
Returns: Promise<string[]>
Read more about WASM Module
Parameters:
text: string— Text to transliteratefrom: ScriptLangType— Source script/languageto: ScriptLangType— Target script/languageoptions?: TransliterationOptions— Custom transliteration options
Returns: Promise<string>
Note: Uses the fast Rust-based WASM implementation for improved performance. Works in all JavaScript environments (Node.js, browsers, Deno, Bun).
Returns: Promise<void>
Note: Preloads the WASM module to avoid initial loading delay when using transliterate_wasm.
Constants & Types
import { SCRIPT_LIST, LANG_LIST, ALL_LANG_SCRIPT_LIST } from 'lipilekhika';
import type { ScriptLangType, TransliterationOptions } from 'lipilekhika';| Export | Description |
|--------|-------------|
| SCRIPT_LIST | Array of all supported script names |
| LANG_LIST | Array of all supported language names mapped to scripts |
| ALL_LANG_SCRIPT_LIST | Combined list of all scripts and languages |
| ScriptLangType | Type for script/language identifiers (includes aliases) |
| TransliterationOptions | Type for custom transliteration options |
| ScriptListType | Type for the script list |
| LangListType | Type for the language list |
⌨️ Real-time Typing
Enable real-time transliteration as users type in <textarea> and <input> elements.
import {
createTypingContext,
handleTypingBeforeInputEvent,
clearTypingContextOnKeyDown
} from 'lipilekhika/typing';📖 Browser Typing Tool Guide • API Reference
Quick Example
import { createTypingContext, handleTypingBeforeInputEvent, clearTypingContextOnKeyDown } from 'lipilekhika/typing';
const ctx = createTypingContext('Telugu');
<textarea
onBeforeInput={(e) => handleTypingBeforeInputEvent(ctx, e, setText)}
onBlur={() => ctx.clearContext()}
onKeyDown={(e) => clearTypingContextOnKeyDown(e, ctx)}
/>API
Parameters:
script: ScriptLangType— Target script/language for typingoptions?: TypingOptions— Custom typing optionsautoContextClearTimeMs?: number(default:4500)useNativeNumerals?: boolean(default:true)includeInherentVowel?: boolean(default:false)
Returns: TypingContext with:
ready: Promise<void>— Await before using (ensures script data loaded)takeKeyInput(char: string)— Process character input and return diffclearContext()— Clear internal stateupdateUseNativeNumerals(value: boolean)— Update numeral preferenceupdateIncludeInherentVowel(value: boolean)— Update inherent vowel inclusion
Parameters:
ctx: TypingContext— Typing contextevent: InputEvent— The beforeinput eventcallback?: (newValue: string) => void— Called with updated valueoptions?— Additional options
Handles keyboard events (Arrow keys, Esc, etc.) to clear context appropriately.
Parameters:
event: KeyboardEvent— The keydown eventctx: TypingContext— Typing context to clear
Additional Utilities
import { getScriptKramaData, getScriptTypingDataMap } from 'lipilekhika/typing';
// Get sequential character array (krama) for a script
const kramaData = await getScriptKramaData('Devanagari');
// Returns: [['अ', 'svara'], ['आ', 'svara'], ['क', 'vyanjana'], ...]
// Get detailed typing mappings for a script
const typingMap = await getScriptTypingDataMap('Telugu');
// Useful for building typing helper UIs🌐 CDN Usage (No Build Step)
<script type="module">
import { transliterate } from 'https://cdn.jsdelivr.net/npm/lipilekhika/dist/esm/index.mjs';
const text = await transliterate('namaste', 'Normal', 'Devanagari');
console.log(text); // नमस्ते
</script><script src="https://cdn.jsdelivr.net/npm/lipilekhika"></script>
<script>
lipilekhika.transliterate('namaste', 'Normal', 'Devanagari')
.then(text => console.log(text)); // नमस्ते
</script>📖 Resources
- Documentation Home — Complete guides and API reference
- JavaScript Guide — Getting started with JS/TS
- Browser Typing Tool — Real-time typing integration
- Supported Scripts — Full list of scripts
- Custom Options — Transliteration options reference
- GitHub Repository — Source code and issues
- Changelog — Version history and updates
