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 🙏

© 2026 – Pkg Stats / Ryan Hefner

sinhala-text-converters

v1.0.5

Published

TypeScript/JavaScript library for converting between Singlish (Sinhala written in English) and Unicode Sinhala. Conversion algorithms originally from Language Technology Research Laboratory - University of Colombo School of Computing (UCSC).

Readme

sinhala-text-converters

A TypeScript/JavaScript library for converting between Singlish (Sinhala written in English) and Unicode Sinhala formats.

Created and maintained by Sinhala Soft Foundation.

Installation

npm install sinhala-text-converters

Usage

TypeScript

import {
  singlishToUnicode,
  unicodeToSinglish,
  convert,
  ConversionOptions
} from 'sinhala-text-converters';

// Convert Singlish to Unicode
const unicode = singlishToUnicode('aayubowan');
console.log(unicode); // Output: ආයුබෝවන්

// Convert Unicode to Singlish
const singlish = unicodeToSinglish('ආයුබෝවන්');
console.log(singlish); // Output: aayubowan

// Use the helper function for conversion
const result = convert('aayubowan', 'singlish', 'unicode');
console.log(result); // Output: ආයුබෝවන්

JavaScript

const {
  singlishToUnicode,
  unicodeToSinglish,
  convert
} = require('sinhala-text-converters');

// Convert Singlish to Unicode
const unicode = singlishToUnicode('aayubowan');
console.log(unicode); // Output: ආයුබෝවන්

// Use the helper function
const result = convert('aayubowan', 'singlish', 'unicode');
console.log(result); // Output: ආයුබෝවන්

API Reference

Functions

singlishToUnicode(text: string, options?: ConversionOptions): string

Converts Singlish (Sinhala written in English) to Unicode Sinhala.

Parameters:

  • text - The Singlish text to convert
  • options - Optional conversion options (see below)

Returns: The converted Unicode Sinhala text

unicodeToSinglish(text: string, options?: ConversionOptions): string

Converts Unicode Sinhala to Singlish.

Parameters:

  • text - The Unicode Sinhala text to convert
  • options - Optional conversion options (see below)

Returns: The converted Singlish text

convert(text: string, from: TextFormat, to: TextFormat, options?: ConversionOptions): string

Helper function to convert text between Singlish and Unicode formats.

Parameters:

  • text - The text to convert
  • from - The source format ('singlish' | 'unicode')
  • to - The target format ('singlish' | 'unicode')
  • options - Optional conversion options (see below)

Returns: The converted text

Throws: Error if an unsupported conversion direction is requested

Types

TextFormat

type TextFormat = 'singlish' | 'unicode';

ConversionOptions

interface ConversionOptions {
  /**
   * Callback function to handle unexpected inputs or conversion issues.
   * Called when an unexpected character or pattern is encountered during conversion.
   */
  onUnexpectedInput?: (
    input: string,
    position: number,
    context: {
      format: TextFormat;
      direction: 'to' | 'from';
      char?: string;
      pattern?: string;
    }
  ) => string | null | undefined;
}

Handling Unexpected Inputs

You can provide a callback function to handle unexpected characters or patterns during conversion:

const options: ConversionOptions = {
  onUnexpectedInput: (input, position, context) => {
    console.warn(`Unexpected input at position ${position}: ${context.char}`);
    // Return a replacement string, or null/undefined to skip
    return '';
  }
};

const result = singlishToUnicode('hello123', options);

Examples

Basic Conversion

import { singlishToUnicode } from 'sinhala-text-converters';

const result = singlishToUnicode('aayubowan');
console.log(result); // Output: ආයුබෝවන්

Using the Helper Function

import { convert } from 'sinhala-text-converters';

// Convert from Singlish to Unicode
const unicode = convert('aayubowan', 'singlish', 'unicode');
console.log(unicode); // Output: ආයුබෝවන්

// Convert from Unicode to Singlish
const singlish = convert('ආයුබෝවන්', 'unicode', 'singlish');
console.log(singlish); // Output: aayubowan

With Error Handling

import { singlishToUnicode, ConversionOptions } from 'sinhala-text-converters';

const options: ConversionOptions = {
  onUnexpectedInput: (input, position, context) => {
    if (context.char && /[0-9]/.test(context.char)) {
      // Replace numbers with empty string
      return '';
    }
    // For other unexpected characters, skip them
    return null;
  }
};

const result = singlishToUnicode('hello123world', options);

Supported Formats

  • Singlish: Sinhala text written using English characters (e.g., "aayubowan")
  • Unicode: Standard Unicode Sinhala characters (e.g., "ආයුබෝවන්")

About

This package is created and maintained by Sinhala Soft Foundation, a non-profit organization dedicated to promoting and developing Sinhala language technology.

Copyright and Attribution

Important: All conversion algorithms originated from the Language Technology Research Laboratory - University of Colombo School of Computing (UCSC).

  • Package Maintainer: Sinhala Soft Foundation
  • Original Source: Language Technology Research Laboratory - University of Colombo School of Computing
  • Original Website: https://ucsc.cmb.ac.lk/ltrl/services/feconverter
  • Copyright: © Language Technology Research Laboratory - University of Colombo School of Computing

All credits for the conversion algorithms go to the authors at UCSC. This package is maintained by Sinhala Soft Foundation.

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues and questions, please open an issue on the GitHub repository.