1.0.1 • Published 8 months ago

currencyswitcher v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

CurrencySwitcher

A simple and efficient currency converter that allows you to convert between multiple currencies. It supports real-time exchange rates to make currency conversion seamless and accurate.


⚠️ Disclaimer

This package was created for learning/testing purposes only. It is not intended for production use. Please do not use this package in any critical or commercial projects.


Features

  • Real-time exchange rates.
  • Convert between multiple currencies.

Installation

You can install the currencyswitcher package via npm:

  npm install currencyswitcher

Usage

To use the currencySwitcher function, import the package and call the function with the required parameters.

import { currencySwitcher } from 'currencyswitcher';

const amountInUSD = 100;
const amountInEUR = await currencySwitcher('USD', 'EUR', amountInUSD);

console.log(`${amountInUSD} USD is equal to ${amountInEUR} EUR.`);

Example Output

If the exchange rate from USD to EUR is 0.85, the output will be:

100 USD is equal to 85 EUR.

Parameters

  • fromCurrency (string): The currency code from which you want to convert (e.g., "USD").
  • toCurrency (string): The currency code to which you want to convert (e.g., "EUR").
  • unit (number): The amount of money you want to convert.

Return Value

The function returns a number representing the converted value in the target currency. It fetches real-time exchange rates via the @everapi/freecurrencyapi-js API.

Code Breakdown

The currencySwitcher function uses the @everapi/freecurrencyapi-js API to get the latest exchange rates and convert the specified amount. You can view the full documentation for the API here: Free Currency API Documentation.

License

This project is licensed under the ISC License.

1.0.1

8 months ago

1.0.0

8 months ago