Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
currency-converter-lt2
Advanced tools
A nodejs currency converter library that doesn't require subscribing to any API calls.
A minimal currency converter library for NodeJS that works out of the box.
Announcement : For crypto currency conversion, check my other package Nodejs Crypto Converter.
This package can be installed using npm
npm install currency-converter-lt
or, yarn
yarn add currency-converter-lt
Import currency-converter-lt
.
const CC = require('currency-converter-lt')
Then instantiate with either the empty constructor
let currencyConverter = new CC()
Or, with a json object
let currencyConverter = new CC({from:"USD", to:"JPY", amount:100})
!!! Note: if you get incorrect conversion described in this issue then make sure you pass isDecimalComma: true
to the constructor as following:
let currencyConverter = new CC({from:"USD", to:"JPY", amount:100, isDecimalComma:true})
The convert method will return the conversion based on the last conversion rate and can be used as a promise.
currencyConverter.convert().then((response) => {
console.log(response) //or do something else
})
convert
can also take the amount as a parameter.
currencyConverter.convert(100).then((response) => {
console.log(response) //or do something else
})
To find the rates use the rates
method.
currencyConverter.rates().then((response) => {
console.log(response) //or do something else
})
Rates can be cached for currency pairs. To implement rate caching, instantiate an object of CurrencyConverter only once in your project, in a CurrencyConverter file, and setup rates caching then import the instance of CurrencyConverter from the CurrencyConverter file in your project across the rest of your project. Use chaining to convert currencies when caching is implemented. Below is an example of a CurrencyConverter file.
Note: Rates are not actually deleted after the ratesCacheDuration. The rate remains in the rates cache of the CurrencyConverter object until a request is made for the same currency pair at which point, the old rate is overwritten.
const CC = require('currency-converter-lt')
let currencyConverter = new CC()
let ratesCacheOptions = {
isRatesCaching: true, // Set this boolean to true to implement rate caching
ratesCacheDuration: 3600 // Set this to a positive number to set the number of seconds you want the rates to be cached. Defaults to 3600 seconds (1 hour)
}
currencyConverter = currencyConverter.setupRatesCache(ratesCacheOptions)
module.exports = currencyConverter
Chaining is also supported.
currencyConverter.from("USD").to("GBP").amount(125).convert().then((response) => {
console.log(response) //or do something else
})
This package uses web scraping to provide the api.
If any issues are found, they can be reported here.
This project is licensed under the MIT license.
FAQs
A nodejs currency converter library that doesn't require subscribing to any API calls.
We found that currency-converter-lt2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.