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

@coreify/taka

v1.0.0

Published

A modern toolkit for formatting and rendering Bangladeshi Taka in JavaScript, TypeScript, and React apps.

Readme

@coreify/taka

A modern toolkit for formatting and rendering Bangladeshi Taka (BDT) in JavaScript, TypeScript, and React.

Built for Bangladesh-first products that need predictable BDT formatting, localized digits, compact amounts, poisha helpers, and small React components without a heavyweight i18n stack.

Why this package

  • Correct symbol, BDT code, and Taka / টাকা display modes
  • en-BD and bn-BD via Intl.NumberFormat
  • Compact notation: South Asian K / L / Cr, international K / M / B, and Bengali localized phrasing (কোটি / লাখ / হাজার)
  • Parse user-facing currency strings (symbol, code, name; glued tokens; optional scientific notation with a currency token)
  • Poisha conversion (100 poisha = 1 taka)
  • bigint and boxed Number where noted
  • SSR-friendly React helpers on a separate entry (@coreify/taka/react)

Installation

npm install @coreify/taka

Requires Node.js 18+ (uses Intl.NumberFormat).

For React:

npm install @coreify/taka react

Quick start

import { formatTaka, formatTakaCompact, parseTaka } from "@coreify/taka";

formatTaka(1250);
// => "৳1,250"

formatTaka(1250, { decimals: 2, trailingZeros: true });
// => "৳1,250.00"

formatTakaCompact(125000);
// => "৳1.25L"

parseTaka("৳1,250.50");
// => 1250.5

parseTaka("not money");
// => null

Formatting

formatTaka accepts a finite number, numeric string, bigint in the safe integer range, or boxed Number.

import { formatTaka } from "@coreify/taka";

formatTaka(2499);
// => "৳2,499"

formatTaka(2499, { currency: "code" });
// => "BDT 2,499"

formatTaka(2499, { style: "name" });
// => "2,499 Taka"

formatTaka(2499, { currencyPosition: "after", space: true });
// => "2,499 ৳"

formatTaka(-2499, { negativeStyle: "accounting" });
// => "(৳2,499)"

formatTaka(0, { zeroFormat: "Free" });
// => "Free"

formatTaka(1234567, { useGrouping: false });
// => "৳1234567"
  • useGrouping defaults to true.
  • zeroFormat: when the coerced amount is exactly 0 (including -0), that string is returned instead of a normal format.
  • String inputs: US / Indian / European-style separators are normalized (see tests). Hex strings (including fullwidth lookalikes such as 0x10) throw TypeError. Out-of-safe-range values throw RangeError.
  • allowScientificNotation: when true, strings like "1e3" are accepted for formatting (no currency token required).
  • allowLooseCommaGrouping: when true, ambiguous comma patterns may be collapsed if the result is a safe plain number (use with care).

Bengali locale

import {
  formatTaka,
  getTakaName,
  toBanglaDigits,
  toEnglishDigits
} from "@coreify/taka";

formatTaka(2499, { locale: "en-BD" });
// => "৳2,499"

formatTaka(2499, { locale: "bn-BD" });
// => "৳২,৪৯৯"

formatTaka(2499, { locale: "bn-BD", style: "name" });
// => "২,৪৯৯ টাকা"

getTakaName("bn");
// => "টাকা"

getTakaName("bn-BD");
// => "টাকা"

getTakaName("bn-IN"); // any "bn-*" subtag → Bengali name
// => "টাকা"

toBanglaDigits("1250.50");
// => "১২৫০.৫০"

toEnglishDigits("১,২৫০.৫০");
// => "1,250.50"

Compact formatting

Short suffixes (K / L / Cr or K / M / B) use scaled decimals. For locale: "bn-BD" with compactLabelStyle: "localized", the amount is instead written with কোটি / লাখ / হাজার so values match how people read them (e.g. 1,250,000১২ লাখ ৫০ হাজার, not ১.২৫ লাখ which would read like 1.25 lakh = 125,000, and not ১.২৫ মিলিয়ন alone).

import { formatTakaCompact } from "@coreify/taka";

formatTakaCompact(1200);
// => "৳1.2K"

formatTakaCompact(125000);
// => "৳1.25L"

formatTakaCompact(10000000);
// => "৳1Cr"

formatTakaCompact(1500000, { compactStyle: "international" });
// => "৳1.5M"

formatTakaCompact(125000, { locale: "bn-BD" });
// => "৳১.২৫L" (short suffix; Bengali digits)

formatTakaCompact(125000, {
  locale: "bn-BD",
  compactLabelStyle: "localized"
});
// => "৳১ লাখ ২৫ হাজার"

formatTakaCompact(1250000, {
  locale: "bn-BD",
  compactLabelStyle: "localized"
});
// => "৳১২ লাখ ৫০ হাজার"

formatTakaCompact(1500000, {
  compactStyle: "international",
  compactLabelStyle: "localized"
});
// => "৳1.5 million" (default English locale)

formatTakaCompact(1000000000, {
  compactStyle: "international",
  compactLabelStyle: "localized",
  locale: "bn-BD"
});
// => "৳১০০ কোটি" (1 billion → 100 crore; not "১ বিলিয়ন")

In JavaScript, 1000000000 and 1_000_000_000 are the same value; underscores are optional and only help readability.

Values with Math.abs(amount) < 1000 use full formatTaka output. For bn-BD + localized, compactStyle (South Asian vs international) does not apply: the Bengali word ladder is always কোটি → লাখ → হাজার.

Poisha (subunits)

ISO 4217 minor units for BDT: 100 poisha = 1 taka.

import {
  formatTaka,
  fromPoisha,
  TAKA_POISHA_PER_TAKA,
  toPoisha
} from "@coreify/taka";

TAKA_POISHA_PER_TAKA;
// => 100

toPoisha(12.5);
// => 1250 (integer poisha)

fromPoisha(1250);
// => 12.5

formatTaka(fromPoisha(toPoisha(12.5)));
// => "৳12.5" (default fraction rules for non-integers)

// Unsafe integer poisha throws RangeError

Parsing

import { isTakaString, normalizeTakaInput, parseTaka } from "@coreify/taka";

parseTaka("৳1,250");
// => 1250

parseTaka("BDT 1,250.50");
// => 1250.5

parseTaka("BDT100");
// => 100 (glued code)

parseTaka("১,২৫০ টাকা");
// => 1250

normalizeTakaInput("৳ ১,২৫০.৫০");
// => "1250.50"

isTakaString("৳1,250");
// => true

parseTaka("(৳1,250)");
// => -1250

parseTaka("(1,250)", { allowParentheses: false });
// => null

Rules:

  • Returns null for unparseable input; throws TypeError if the string contains a hex literal (same rule as formatTaka for string coercion).
  • allowScientificNotation: when true, scientific forms are allowed only if a Taka token is present (e.g. "৳1e3", "BDT1e3"). Bare "1e3" is still rejected.
  • allowLooseCommaGrouping: same idea as formatting; opt-in for ambiguous comma groupings.
  • More than one (U+09F3) in the input is rejected (null).
  • Safe range: amounts beyond Number.MAX_SAFE_INTEGER round-tripping rules return null (no silent rounding).

normalizeTakaInput: strips currency markers and normalizes grouping for further processing; does not throw on hex (use parseTaka / formatTaka for strict hex rejection).

Advanced: formatCoercedAmount

If you already coerced a value with the same options object shape (e.g. after parseTaka), format the number without parsing again:

import { formatCoercedAmount, formatTaka } from "@coreify/taka";

const amount = 1250;
formatCoercedAmount(amount, { locale: "bn-BD", style: "name" });
// same result as formatTaka(amount, { ... }) for that amount

formatTaka is implemented as coerce-then-formatCoercedAmount.

React

Helpers live under @coreify/taka/react so the core bundle stays React-free. The published dist/react.js / dist/react.cjs files are built so a top-level "use client" directive remains present after minification (Next.js App Router / RSC client boundaries).

import { TakaAmount, TakaSymbol, TakaText } from "@coreify/taka/react";

function PriceCard() {
  return (
    <div>
      <p>
        <TakaSymbol srLabel="Taka" />
      </p>
      <p>
        <TakaAmount value={1250} />
      </p>
      <p>
        <TakaText value={1250} locale="bn-BD" />
      </p>
    </div>
  );
}
  • TakaSymbol, TakaAmount, TakaText: forwardRef to the root span. DOM props match React.ComponentPropsWithoutRef<"span">, except children is omitted (content comes from formatting or the symbol).
  • TakaSymbol: renders . Default aria-label: "Bangladeshi Taka"; override with srLabel or aria-label.
  • TakaAmount: default display aligns with formatTaka (symbol style). Accepts variant / currency / style plus decimals, trailingZeros, useGrouping, currencyPosition, space, negativeStyle, zeroFormat, allowScientificNotation, allowLooseCommaGrouping, locale. Formatting options are not forwarded as DOM attributes.
  • TakaText: same props as TakaAmount, defaulting to name style (e.g. "1,250 Taka" / Bengali equivalent with locale). Use variant="symbol" for symbol output.
  • srLabel wins over a spread aria-label. If neither is set, TakaAmount / TakaText derive an accessible name from a name-style format of the same numeric options.

API reference

Core

| Export | Description | | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | | formatTaka(value, options?) | Format BDT per TakaFormatOptions. | | formatCoercedAmount(amount, options?) | Format an already-coerced number. | | formatTakaCompact(value, options?) | Compact form; TakaCompactOptions. | | parseTaka(input, options?) | number \| null; ParseTakaOptions. | | normalizeTakaInput(input, options?) | Stripped/normalized numeric string. | | isTakaString(input, options?) | boolean; false for hex or multiple . | | toBanglaDigits / toEnglishDigits | Digit scripts. | | toPoisha / fromPoisha | Poisha conversion; throws if non-finite or unsafe integer poisha. | | TAKA_POISHA_PER_TAKA | 100 | | getTakaSymbol / getTakaCode / getTakaName | Constants helpers; name resolves bn, bn-BD, bn-*, en, en-BD, en-*; otherwise English Taka. |

Constants

TAKA_SYMBOL (), TAKA_CODE (BDT), TAKA_NAME_EN, TAKA_NAME_BN.

Types

TakaLocale, TakaLanguage, TakaCurrencyDisplay, TakaCurrencyPosition, TakaCompactStyle, TakaCompactLabelStyle, TakaNegativeStyle, TakaNumericInput, TakaFormatOptions, TakaCompactOptions, ParseTakaOptions.

TypeScript

Strict TypeScript, declaration files for @coreify/taka and @coreify/taka/react. Core types do not import React, so non-React apps need not add react for the main entry.

License

MIT