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

bangla-num-converter

v1.0.3

Published

A TypeScript library that converts English numbers to Bengali (Bangla) numerals with support for formatting options.

Downloads

8

Readme

Bangla Number Converter

A TypeScript library that converts English numbers to Bengali (Bangla) numerals with support for formatting options.

Features

  • Convert numbers to Bengali numerals
  • Support for both number and string inputs
  • Preserve or remove commas in formatted numbers
  • Handle decimal numbers and negative values
  • Type-safe with full TypeScript support
  • Zero dependencies

Installation

npm install bangla-num-converter

Usage

Basic Usage

import enToBn from "bangla-num-converter";

// Converting numbers
console.log(enToBn(123)); // Returns: ১২৩
console.log(enToBn(1000.5)); // Returns: ১০০০.৫০
console.log(enToBn(-42)); // Returns: -৪২

// Converting strings with commas
console.log(enToBn("1,234,567")); // Returns: ১,২৩৪,৫৬৭

Formatting Options

You can control comma preservation in the output:

// With commas (default)
console.log(enToBn("1,234,567")); // Returns: ১,২৩৪,৫৬৭

// Without commas
console.log(enToBn("1,234,567", false)); // Returns: ১২৩৪৫৬৭

Return Types

The function returns different types based on the input:

// Numbers return as numbers
const result1 = enToBn(123); // Type: number, Value: 123

// Strings return as strings
const result2 = enToBn("1,234"); // Type: string, Value: "১,২৩৪"

Utility Functions

The package also exports utility functions for working with Bengali numerals:

import { isBengaliDigit, BENGALI_DIGITS } from "bangla-num-converter";

// Check if a character is a Bengali digit
console.log(isBengaliDigit("১")); // true
console.log(isBengaliDigit("1")); // false

// Access all Bengali digits
console.log(BENGALI_DIGITS); // ['০', '১', '২', '৩', '৪', '৫', '৬', '৭', '৮', '৯']

Input Validation

The library includes strict input validation:

  • Only accepts valid numbers, commas, decimal points, and negative signs
  • Throws error for multiple decimal points
  • Throws error for multiple negative signs
  • Throws error for invalid characters
// These will throw errors
enToBn("abc"); // Error: Invalid characters
enToBn("1.2.3"); // Error: Multiple decimal points
enToBn("--123"); // Error: Multiple negative signs
enToBn("123abc"); // Error: Invalid characters

API Reference

Main Function

function enToBn(
  number: number | string,
  preserveCommas: boolean = true
): number | string;

Parameters

  • number: The number or string to convert
  • preserveCommas (optional): Whether to preserve commas in the output (default: true)

Returns

  • Returns number if the input is a number
  • Returns string if the input is a string or contains formatting

Utility Functions

function isBengaliDigit(char: string): boolean;
  • Checks if a character is a Bengali numeral
const BENGALI_DIGITS: string[];
  • Array of all Bengali numerals (০-৯)

Error Handling

The library throws descriptive errors for invalid inputs:

try {
  enToBn("123@456");
} catch (error) {
  console.error(error.message);
  // "Input must only contain numbers, commas, periods, or hyphens"
}

License

MIT

Contributing

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

Author

Chowdhury Tafsir Ahmed Siddiki

Support

If you find any bugs or have feature requests, please create an issue on GitHub.