Registry / finance / sl-currency-formatter

sl-currency-formatter

JSON →
library1.1.2jsnpmunverified

A simple JavaScript/TypeScript library for formatting numbers as Sri Lankan Rupees (LKR). Current stable version 1.1.2, single release to date. Supports comma-separated output, cents display, language-prefixed output (English, Sinhala, Tamil), and custom prefix/suffix codes. Minimal zero-dependency utility focused on LKR formatting, unlike generic formatters (e.g., Intl.NumberFormat).

npm install sl-currency-formatter
INSTALL
IMPORT
SIG · SL-CURRENCY-FORMAT
S
sl-currency-formatter
financejavascriptv1.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

formatSLR
✓ import { formatSLR } from 'sl-currency-formatter'
✗ const formatSLR = require('sl-currency-formatter')
Default import does not exist; must use named import. CJS require is also valid but less common in TypeScript projects.
FormatOptions
✓ import type { FormatOptions } from 'sl-currency-formatter'
✗ import { FormatOptions } from 'sl-currency-formatter'
FormatOptions is a TypeScript interface only, export may be type-only. For type-only imports prefer `import type` to avoid runtime errors.
default
✓ import { formatSLR } from 'sl-currency-formatter'
✗ import formatSLR from 'sl-currency-formatter'
No default export; package exports only named `formatSLR`.

Shows basic formatting of a number with default options, stripping commas and cents, and using Tamil language prefix formatting.

import { formatSLR } from 'sl-currency-formatter'; console.log(formatSLR(123456.78)); // Output: "Rs. 1,23,456.78 /=" console.log(formatSLR('5000', { commas: false, cents: false, prefix: false })); // Output: "5000 /=" console.log(formatSLR(1000.50, { lang: 'tamil', prefix: false })); // Output: "1,000.50 /="
Debug
Known issues
gotchaInput value may be a string, but non-numeric strings will cause unexpected output.
fix
Always parse numeric strings to number before passing, or ensure input is a valid numeric string.
affects: >=1.0.0
gotchaThe `lang` option accepts only three values: 'english', 'sinhala', 'tamil'. Using an unsupported string may fallback to default or error.
fix
Use only 'english', 'sinhala', or 'tamil' for the `lang` option.
affects: >=1.0.0
deprecatedThe default `prefixCode` is 'Rs.' and `suffixCode` is ' /='. These are not configurable via language; they stay constant regardless of lang.
fix
If you need language-specific prefixes, manipulate the prefixCode yourself.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: formatSLR is not a function
Using default import instead of named import.
fix
Use `import { formatSLR } from 'sl-currency-formatter'` instead of `import formatSLR from '...'`.
Cannot find module 'sl-currency-formatter'
Package might not be installed or spelling incorrect.
fix
Run `npm install sl-currency-formatter` and check package.json.
Input must be a number or a numeric string
Passed a non-numeric value to formatSLR.
fix
Ensure the value is either a number or a string that can be parsed as a number (e.g., '123').
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
24
Resources