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

@stndrds/constants

v1.0.0-alpha.345

Published

Currency and country data with ISO codes

Readme

@stndrds/constants

Standard constants library for And You Create applications.

Provides type-safe constants for:

  • 🌍 Countries (ISO codes, phone codes)
  • 💰 Currencies (codes, symbols, decimals)
  • 🎨 Colors
  • 🔤 Icons
  • 📁 File sizes
  • 📄 MIME types

Installation

pnpm add @stndrds/constants

Usage

Countries

import { COUNTRIES, getCountryByIso2, isValidIso2 } from "@stndrds/constants";

// Get country by ISO2 code
const france = COUNTRIES.FR;
console.log(france.name);        // "France"
console.log(france.phoneCode);   // "+33"

// Lookup functions
const country = getCountryByIso2("FR");
const isValid = isValidIso2("FR"); // true

// Type-safe ISO codes
import type { CountryIso2, CountryIso3 } from "@stndrds/constants";
const code: CountryIso2 = "FR"; // Type-safe

Currencies

import { CURRENCIES, getCurrency, getCurrencySymbol } from "@stndrds/constants";

// Get currency
const euro = CURRENCIES.EUR;
console.log(euro.name);     // "Euro"
console.log(euro.symbol);   // "€"
console.log(euro.decimals); // 2

// Helper functions
const symbol = getCurrencySymbol("EUR"); // "€"
const currency = getCurrency("USD");

// Type-safe currency codes
import type { CurrencyCode } from "@stndrds/constants";
const code: CurrencyCode = "EUR"; // Type-safe

File Sizes

import { FILE_SIZE, RECOMMENDED_MAX_SIZES, mbToBytes } from "@stndrds/constants";

// Intuitive constants
const avatarMaxSize = FILE_SIZE.MB_2;      // 2,097,152 bytes
const documentMaxSize = FILE_SIZE.MB_10;   // 10,485,760 bytes
const videoMaxSize = FILE_SIZE.MB_500;     // 524,288,000 bytes

// Recommended sizes by use case
const maxSize = RECOMMENDED_MAX_SIZES.AVATAR;    // 2 MB
const maxSize = RECOMMENDED_MAX_SIZES.DOCUMENT;  // 10 MB
const maxSize = RECOMMENDED_MAX_SIZES.VIDEO;     // 500 MB

// Conversion utilities
const bytes = mbToBytes(5);           // 5,242,880

// Validation
import { isWithinSizeLimit } from "@stndrds/constants";
const isValid = isWithinSizeLimit(1048576, FILE_SIZE.MB_5); // true

MIME Types

import {
  IMAGE_MIME_TYPES,
  DOCUMENT_MIME_TYPES,
  VIDEO_MIME_TYPES,
  WEB_IMAGES,
  OFFICE_DOCUMENTS,
  isImageMimeType,
} from "@stndrds/constants";

// Individual MIME types
const jpeg = IMAGE_MIME_TYPES.JPEG;  // "image/jpeg"
const pdf = DOCUMENT_MIME_TYPES.PDF; // "application/pdf"
const mp4 = VIDEO_MIME_TYPES.MP4;    // "video/mp4"

// Grouped collections
const webImages = WEB_IMAGES;           // ["image/jpeg", "image/png", "image/gif", "image/webp"]
const officeFiles = OFFICE_DOCUMENTS;   // [PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX]

// Type checking
const isImage = isImageMimeType("image/jpeg"); // true
const isDoc = isDocumentMimeType("application/pdf"); // true

// Type-safe MIME types
import type { MimeType, ImageMimeType } from "@stndrds/constants";
const type: MimeType = "image/jpeg"; // Type-safe

Integration with @stndrds/schema

import { file, location, currency, phone } from "@stndrds/schema";
import {
  FILE_SIZE,
  WEB_IMAGES,
  DOCUMENT_MIME_TYPES,
  RECOMMENDED_MAX_SIZES,
} from "@stndrds/constants";

// File attribute with MIME type validation
const avatar = file({ id: "avatar", name: "avatar", label: "Avatar" })
  .maxSize(RECOMMENDED_MAX_SIZES.AVATAR)
  .allowedTypes(WEB_IMAGES)
  .build();

// Document upload
const document = file({ id: "doc", name: "document", label: "Document" })
  .maxSize(FILE_SIZE.MB_10)
  .allowedTypes([DOCUMENT_MIME_TYPES.PDF, DOCUMENT_MIME_TYPES.DOCX])
  .build();

// Location with country restriction
const address = location({ id: "addr", name: "address", label: "Address" })
  .granularity("full")
  .defaultCountry("FRA")
  .allowedCountries(["FRA", "DEU", "GBR"])
  .build();

// Currency with restrictions
const price = currency({ id: "price", name: "price", label: "Price" })
  .defaultCurrency("EUR")
  .allowedCurrencies(["EUR", "USD", "GBP"])
  .build();

// Phone with default country
const mobile = phone({ id: "phone", name: "phone", label: "Phone" })
  .defaultCountry("FRA")
  .build();

Available Constants

Countries

60+ countries with ISO2, ISO3, numeric codes, and phone codes

Currencies

50+ currencies with codes, symbols, and decimal precision

File Sizes

  • Bytes: B_1, B_10, B_100, B_512
  • Kilobytes: KB_1, KB_2, KB_5, KB_10, KB_50, KB_100, KB_500
  • Megabytes: MB_1, MB_2, MB_5, MB_10, MB_20, MB_25, MB_50, MB_100, MB_200, MB_500
  • Gigabytes: GB_1, GB_2, GB_5, GB_10

MIME Types

  • Images: JPEG, PNG, GIF, WebP, SVG, BMP, TIFF, HEIC, HEIF
  • Documents: PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, ODT, TXT, CSV, Markdown
  • Archives: ZIP, RAR, TAR, GZIP, 7Z, BZ2
  • Audio: MP3, WAV, OGG, AAC, FLAC, M4A
  • Video: MP4, WebM, OGG, AVI, MOV, MKV
  • Code: JavaScript, TypeScript, JSON, XML, HTML, CSS, Python, Java
  • Fonts: TTF, OTF, WOFF, WOFF2

Testing

# Run tests
pnpm test

# Run tests with coverage
pnpm test:coverage

Types

All exports are fully typed with TypeScript.

import type {
  CountryIso2,
  CountryIso3,
  CurrencyCode,
  MimeType,
  ImageMimeType,
  DocumentMimeType,
} from "@stndrds/constants";

License

Licensed under the Standards SDK License 1.0 — see LICENSE. This package is not open source: it is provided to build applications that communicate with Standards.