Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

currency-formatters

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

currency-formatters

Empower your applications with our comprehensive currency formatter npm package. Seamlessly handle currency and number formatting with ease, whether you're dealing with monetary values or numeric representations. Our versatile library supports a wide rang

  • 1.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-96.59%
Maintainers
1
Weekly downloads
 
Created
Source

Currency Formatter

NPM Version License Build Status

currency-formatter is a TypeScript and React utility package for formatting numbers as currencies using various numbering systems (Indian, US, European) with appropriate currency symbols.

example

Features

  • 📈 Supports multiple numbering systems: Indian, US, and European.
  • 💱 Includes currency symbols for easy integration.
  • ⚛️ Designed for use with React and TypeScript.

Installation

To install the package, run:

npm install currency-formatters

Usage

Here's how to use currency-formatters in a React application:

// src/App.tsx

import React from 'react';
import { useCurrencyFormatter } from 'currency-formatter'; // Import the hook from the package

const App: React.FC = () => {
  const formatINR = useCurrencyFormatter({
    numberingSystem: 'indian',
    currency: '₹'
  });

  const formatUSD = useCurrencyFormatter({
    numberingSystem: 'us',
    currency: '$'
  });

  const formatEUR = useCurrencyFormatter({
    numberingSystem: 'european',
    currency: '€'
  });

  return (
    <div style={{ padding: '20px', fontFamily: 'Arial, sans-serif' }}>
      <h1 style={{ color: '#4CAF50' }}>Currency Formatter Example</h1>
      <p><strong>INR:</strong> {formatINR(100000)}</p>
      <p><strong>USD:</strong> {formatUSD(100000)}</p>
      <p><strong>EUR:</strong> {formatEUR(100000)}</p>
    </div>
  );
};

export default App;

Function

useCurrencyFormatter

A custom React hook that formats a number as a currency string based on the specified numbering system and currency symbol.

Parameters numberingSystem: string - The numbering system to use. Possible values are 'indian', 'us', and 'european'. currency: string - The currency symbol to use.

Example

const formatINR = useCurrencyFormatter({
  numberingSystem: 'indian',
  currency: '₹'
});

console.log(formatINR(100000)); // Outputs: ₹1L

Contributions

Contributions are welcome! Please open an issue or submit a pull request for any changes.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

FAQs

Package last updated on 23 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc