format

Utilities for data formatting like currency and phone numbers.

Functions

Function
Description
Example

currency

Format a number as currency

dphelper.format.currency(value, locale, currency)

phoneNumber

Format a string as a phone number

dphelper.format.phoneNumber(value, countryCode)

Description

Data formatting utilities:

  • Currency - Format numbers with locale-specific currency symbols using Intl API

  • Phone Numbers - Format phone numbers by country code

  • Localization - Supports multiple locales (en-US, de-DE, ja-JPY, etc.)

Usage Examples

Currency Formatting

// Basic USD currency (default)
const price = dphelper.format.currency(1234.56);
// Output: "$1,234.56"

// Euro currency with German locale
const euro = dphelper.format.currency(1234.56, 'de-DE', 'EUR');
// Output: "1.234,56 €"

// Japanese Yen
const yen = dphelper.format.currency(5000, 'ja-JPY', 'JPY');
// Output: "¥5,000"

// British Pound
const pound = dphelper.format.currency(99.99, 'en-GB', 'GBP');
// Output: "£99.99"

// Swiss Franc
const franc = dphelper.format.currency(1500, 'de-CH', 'CHF');
// Output: "CHF 1'500.00"

Phone Number Formatting

E-commerce Price Display

International Checkout

Details

  • Author: Dario Passariello

  • Version: 0.0.2

  • Creation Date: 20210101

  • Last Modified: 20260220

  • Environment: both (browser + Node.js)


Automatically generated document

Last updated