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 🙏

© 2024 – Pkg Stats / Ryan Hefner

intl-data

v1.0.11

Published

Tiny module to retrieve locale and currency data from native builtin Intl object without locale data transfer or additional locale files.

Downloads

86

Readme

intl-data

Tiny module to retrieve locale and currency data from native builtin Intl object without locale data transfer or additional locale files.

Installation

| Format | Instructions | | ---------------------------------- | ------------------------------------------------------ | | TypeScript | import { ... } from "intl-data"; | | Node (CommonJS) | const { ... } = require("intl-data"); | | ES Modules (Browsers, webpack) | import { ... } from "intl-data"; | | UMD (Browser Global) | <script src="path/to/umd/intl-data.js"></script> | | UMD (Browser Global) (min) | <script src="path/to/umd/intl-data.min.js"></script> |

All unminified and minified bundle files are located in respective directories named after format (cjs, esm, umd) in dist (dist/cjs/intl-data.js and intl-data.min.js)

Synopsis

import { getLocale, getCurrency } from "intl-data";

const locale = getLocale("tr-TR"); // { digitGroupSeparator: ".", decimalCharacter: ",", currencySymbolPlacement: "p", percentSymbolPlacement: "p", percentSymbol: "%" }
const currency = getCurrency("TRY"); // { symbol: "₺", decimalPlaces: 2 }
const currency = getCurrency("TRY", "en-US"); // { symbol: '₺', decimalPlaces: 2, name: 'Turkish Lira' }

Details

Retrieves locale and currency.

Modern browsers and node.js have builtin Intl object, and this module uses this object. As a result it does not need to transfer additional locale files or data.

API

intl-data

intl-data

Table of contents

Interfaces

Functions

Functions

getCurrency

getCurrency<T>(currencyCode: T, locale?: string): T

Type parameters:

| Name | Type | | ---- | ----------- | ------ | | T | undefined | null |

Parameters:

| Name | Type | | -------------- | -------- | | currencyCode | T | | locale? | string |

Returns: T

Defined in: intl-data.ts:37

getCurrency(currencyCode: string | null | undefined, locale?: string): Currency | null | undefined

Parameters:

| Name | Type | | -------------- | -------- | ------ | ----------- | | currencyCode | string | null | undefined | | locale? | string |

Returns: Currency | null | undefined

Defined in: intl-data.ts:38


getLocale

getLocale(localeCode: string): Locale

Parameters:

| Name | Type | | ------------ | -------- | | localeCode | string |

Returns: Locale

Defined in: intl-data.ts:79

getLocale<T>(localeCode: T): T

Type parameters:

| Name | Type | | ---- | ----------- | ------ | | T | undefined | null |

Parameters:

| Name | Type | | ------------ | ---- | | localeCode | T |

Returns: T

Defined in: intl-data.ts:80

getLocale(localeCode: string | null | undefined): Locale | undefined | null

Parameters:

| Name | Type | | ------------ | -------- | ------ | ----------- | | localeCode | string | null | undefined |

Returns: Locale | undefined | null

Defined in: intl-data.ts:81

Interfaces

intl-data / Currency

Interface: Currency

Information about currency

Hierarchy

  • Currency

Table of contents

Properties

Properties

code

code: string

ISO 4217 currency codes

Defined in: intl-data.ts:27


decimalPlaces

decimalPlaces: number

Number of digits used in decimal (fractional) part of the currency.

Defined in: intl-data.ts:29


name

name: string

Name of the currency.

Defined in: intl-data.ts:25


symbol

symbol: string

Currency symbol such as , $,

Defined in: intl-data.ts:31

intl-data / Locale

Interface: Locale

Information about locale.

Hierarchy

  • Locale

Table of contents

Properties

Properties

code

code: string

BCP 47 language tag of the locale. This is simply string provided to get locale. Example: tr-TR

Defined in: intl-data.ts:9


currencySymbolPlacement

currencySymbolPlacement: p | s

Place of currency symbol: p for prefix such as $1.95, or s for suffix such as 1.95$

Defined in: intl-data.ts:15


decimalCharacter

decimalCharacter: string

Character to separate decimal (fraction) parts of the number from integer parts.

Defined in: intl-data.ts:11


digitGroupSeparator

digitGroupSeparator: string

Grouping separators for integer parts, such as thousands separators or thousand/lakh/crore separators.

Defined in: intl-data.ts:13


percentSymbol

percentSymbol: string

Percent symbol. Some locales contains spcae for percent symbol such as 12 %, and some not 12%. This is used to differenciate them.

Defined in: intl-data.ts:19


percentSymbolPlacement

percentSymbolPlacement: p | s

Place of percent symbol: p for prefix such as %12, or s for suffix such as 12%

Defined in: intl-data.ts:17