Socket
Socket
Sign inDemoInstall

@prygun/currency-converter

Package Overview
Dependencies
7
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @prygun/currency-converter

Module for currency conversion


Version published
Maintainers
1
Created

Readme

Source

@prygun/currency-converter

Description

This is a module for converting currency. It uses the OpenExchangeRates API to retrieve the current exchange rates for various currencies.

Installation

To install this module, run the following command:

npm install @prygun/currency-converter

Usage

To use this module, first import the convertCurrency function:

import { convertCurrency } from '@prygun/currency-converter';

Then, call the function with the desired fromCurrency, toCurrency, and amount parameters:

const convertedAmount = await convertCurrency('USD', 'EUR', 10);
console.log(convertedAmount);

Error Handling

If any required parameters are missing or an error occurs during conversion, an error will be thrown. You should wrap calls to convertCurrency in a try-catch block to handle these errors:

try {
  const convertedAmount = await convertCurrency('USD', 'XYZ', 10);
  console.log(convertedAmount);
} catch (error) {
  console.error(error.message);
}

Configuration

To use this module, you will need to set the OPENEXCHANGERATES_API_KEY environment variable to your API key for the OpenExchangeRates API. You can obtain an API key by signing up for a free account on their website: https://openexchangerates.org/signup

License

This module is licensed under the ISC License. See the LICENSE file for details.

Keywords

FAQs

Last updated on 10 Mar 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc