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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@develit-io/general-codes

v1.14.0

Published

General Codes

Downloads

3,083

Readme

@develit-io/general-codes

📦 @develit-io/general-codes is a utility package that provides standardized codes for countries, currencies, banks, languages, and exchange rate providers. It serves as a central repository for handling common reference data in applications.

📥 Installation

pnpm add @develit-io/general-codes

🚀 Features

  • 🌍 Countries – Standardized country codes and names.
  • 💱 Currencies – Includes fiat and crypto currencies with provider mapping.
  • 🏦 Banks – Bank codes and names.
  • 🗣 Languages – Language codes and names.
  • 🌐 Crypto Networks – Blockchain networks for cryptocurrency support.
  • 🔗 Currency Providers – Defines supported exchange rate providers with configurable API endpoints.

📚 Usage

Importing Data

import {
  CODES,
  BANKS,
  COUNTRIES,
  CURRENCIES,
  LANGUAGES,
  CRYPTO_NETWORKS,
  CURRENCY_PROVIDERS,
  FIAT_CURRENCIES,
  CRYPTO_CURRENCIES,
  CURRENCY_TYPES
} from "@develit-io/general-codes";

console.log(COUNTRIES); // List of country codes
console.log(CURRENCIES); // List of all currencies (fiat + crypto)
console.log(FIAT_CURRENCIES); // List of fiat currencies only
console.log(CRYPTO_CURRENCIES); // List of crypto currencies only
console.log(BANKS); // List of banks
console.log(LANGUAGES); // Language codes
console.log(CRYPTO_NETWORKS); // Blockchain networks
console.log(CURRENCY_PROVIDERS); // Exchange rate providers

// Importing types
const country: CODES.Country = {...};
const currency: CODES.Currency = {...};
const cryptoNetwork: CODES.CryptoNetwork = {...};

🔹 Data Structure

🌍 Countries (COUNTRIES)

Each country entry follows this structure:

type Country = {
  code2: string;
  code3: string;
  currency: string;
  phoneCode: string;
  name: string;
  native: string;
  vat: number;
  priority?: number;
  translatedName?: string;
  sanctions?: boolean;
};

💱 Currencies (CURRENCIES)

Currencies include fiat and crypto, each having a type and supported providers.

type Currency = {
  code: string;
  symbol: string;
  symbolBefore: boolean;
  name: string;
  providers: CurrencyProvider[];
  decimals: number;
  networks?: string[] | null;
  type: 'FIAT' | 'CRYPTO';
};

🏦 Banks (BANKS)

Each bank entry follows this structure:

interface Bank {
  name: string
  code: string
  country: string
};

🗣 Languages (LANGUAGES)

Languages are stored as ISO codes with names.

type Language = {
  code: string;
  name: string;
  native: string;
  cs: string;
};

🌐 Crypto Networks (CRYPTO_NETWORKS)

Blockchain networks for cryptocurrency support.

type CryptoNetwork = {
  code: string;
  name: string;
  nativeCurrency: string;
  chainId?: number;
  rpcUrl?: string;
  explorerUrl?: string;
};

Example networks:

const CRYPTO_NETWORKS = [
  {
    code: 'ETH',
    name: 'Ethereum',
    nativeCurrency: 'ETH',
    chainId: 1,
    rpcUrl: 'https://mainnet.infura.io/v3/',
    explorerUrl: 'https://etherscan.io',
  },
  {
    code: 'BSC',
    name: 'Binance Smart Chain',
    nativeCurrency: 'BNB',
    chainId: 56,
    rpcUrl: 'https://bsc-dataseed1.binance.org',
    explorerUrl: 'https://bscscan.com',
  },
  {
    code: 'POLYGON',
    name: 'Polygon',
    nativeCurrency: 'MATIC',
    chainId: 137,
    rpcUrl: 'https://polygon-rpc.com',
    explorerUrl: 'https://polygonscan.com',
  },
  // ... more networks
];

🔗 Currency Providers (CURRENCY_PROVIDERS)

Defines API providers for currency exchange rates, with endpoint templates.

type CurrencyProviderId = 'currencyLayer' | 'currencyCloud' | 'CNB' | 'kraken' | 'binance';

type CurrencyProvider = {
  id: CurrencyProviderId;
  url: string;
};

Example provider definitions:

const CURRENCY_PROVIDERS = [
  { id: "currencyLayer", url: "https://api.currencylayer.com/live?access_key={access_key}&currencies={target}&source={base}" },
  { id: "currencyCloud", url: "https://api.currencycloud.com/v2/rates/detailed?buy_currency={target}&sell_currency={base}" },
  { id: "kraken", url: "https://api.kraken.com/0/public/Ticker?pair={base}{target}" },
  { id: "binance", url: "https://api.binance.com/api/v3/ticker/price?symbol={base}{target}" },
  { id: "CNB", url: "https://api.cnb.cz/cnbapi/exrates/daily" }
];

💡 Usage Examples

Working with Cryptocurrencies and Crypto Networks

All cryptocurrency entries have type: 'CRYPTO' and assigned networks (never null), while fiat currencies have type: 'FIAT' and networks: null.

import { CURRENCIES, CRYPTO_NETWORKS } from "@develit-io/general-codes";

// Find Ethereum currency
const eth = CURRENCIES.find(c => c.code === 'ETH');
console.log(eth?.networks); // ['ETH', 'ARBITRUM', 'OPTIMISM', 'POLYGON']

// Find networks where ETH can be used
const ethNetworks = CRYPTO_NETWORKS.filter(n =>
  eth?.networks?.includes(n.code)
);

// Get network details for a specific chain
const ethereumMainnet = CRYPTO_NETWORKS.find(n => n.code === 'ETH');
console.log(ethereumMainnet?.chainId); // 1

// Find all currencies available on Polygon
const polygonCurrencies = CURRENCIES.filter(c =>
  c.networks?.includes('POLYGON')
);

// Get all crypto currencies using type field
const cryptoCurrencies = CURRENCIES.filter(c => c.type === 'CRYPTO');

// Get all fiat currencies using type field
const fiatCurrencies = CURRENCIES.filter(c => c.type === 'FIAT');

// Alternative: filter by networks (same result)
const cryptosByNetworks = CURRENCIES.filter(c => c.networks !== null);
const fiatsByNetworks = CURRENCIES.filter(c => c.networks === null);

🧰 Utility Functions

The library includes a comprehensive set of utility functions for working with currencies and networks:

import { UTILS } from "@develit-io/general-codes";

// Or import specific functions
import {
  getCurrencyByCode,
  formatCurrency,
  getNetworksForCurrency
} from "@develit-io/general-codes";

Currency Helpers

// Get currency information
const btc = UTILS.getCurrencyByCode('BTC');
console.log(btc?.decimals); // 8

// Check currency types
UTILS.isFiatCurrency('USD'); // true
UTILS.isCryptoCurrency('BTC'); // true

// Get currencies by type
const fiats = UTILS.getFiatCurrencies();
const cryptos = UTILS.getCryptoCurrencies();

Network Helpers

// Get network information
const ethereum = UTILS.getNetworkByCode('ETH');
console.log(ethereum?.chainId); // 1

// Find currencies on a network
const polygonTokens = UTILS.getCurrenciesByNetwork('POLYGON');
// Returns: [ETH, MATIC]

// Find networks for a currency
const ethNetworks = UTILS.getNetworksForCurrency('ETH');
// Returns: [ETH, ARBITRUM, OPTIMISM, POLYGON]

// Check if currency is multi-chain
UTILS.isMultiChainCurrency('ETH'); // true
UTILS.isMultiChainCurrency('BTC'); // false

Currency Formatting

// Format currency amounts
UTILS.formatCurrency(1.23456789, 'BTC');
// "₿1.23456789"

UTILS.formatCurrency(1000, 'USD');
// "$1,000.00"

UTILS.formatCurrency(1000, 'JPY');
// "¥1,000"

// Custom formatting options
UTILS.formatCurrency(1000, 'EUR', {
  locale: 'de-DE',
  showSymbol: false
});
// "1.000,00"

// Get currency properties
UTILS.getCurrencyDecimals('BTC'); // 8
UTILS.getCurrencySymbol('USD'); // "$"
UTILS.isSymbolBefore('EUR'); // false

Provider Helpers

// Get providers for a currency
UTILS.getCurrencyProviders('BTC');
// ['kraken', 'binance']

// Get currencies by provider
UTILS.getCurrenciesByProvider('kraken');
// [BTC, ETH, ADA, ...]

// Check if currency has specific provider
UTILS.hasProvider('BTC', 'binance'); // true

Validation

// Validate codes
UTILS.isValidCurrencyCode('BTC'); // true
UTILS.isValidNetworkCode('ETH'); // true

// Validate currency-network pairs
UTILS.validateCurrencyNetworkPair('ETH', 'POLYGON'); // true
UTILS.validateCurrencyNetworkPair('BTC', 'ETH'); // false

Search Functions

// Search currencies
UTILS.searchCurrencies('bit');
// Returns currencies containing "bit" in code, name, or symbol

// Search networks
UTILS.searchNetworks('ethereum');
// Returns networks containing "ethereum" in code, name, or nativeCurrency

Amount Conversion

// Convert between different decimal precisions
UTILS.convertCurrencyAmount(100, 2, 8);
// Converts 100 (2 decimals) to 10000000 (8 decimals)

// Normalize amount to specific decimals
UTILS.normalizeAmount(1.5, 'USD', 8);
// Converts 1.5 USD (2 decimals) to 150000000 (8 decimals)

To contribute or modify, install dependencies and build:

pnpm install
pnpm build

Run tests:

pnpm test

📄 License

Open Source © Develit.io - Made with 💚