Socket
Socket
Sign inDemoInstall

y-currency

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    y-currency

A module that enables fast and easy currency/ies conversion using the Yahoo Finance API.


Version published
Weekly downloads
8
Maintainers
1
Install size
20.5 kB
Created
Weekly downloads
 

Readme

Source

Instalation

npm install y-currency

y-currency

Easy currency conversion using the yahoo api.

Version: 1.0.2
Author: Matas Kairaitis
License: MIT

y-currency.convert(values, from, to, cb)

Converts the provided values to another currency in one request.

Kind: static method of y-currency
Summary: When converting multiple values you should always pass them as an array instead of calling this function multiple times. This way you minimize the amount of requests that are made.

ParamTypeDescription
valuesnumber | Array.<number>A string or array of strings of the amounts to convert.
fromstringThe currency symbol to convert from. Will return an error if the symbol is not supported.
tostringThe currency symbol to convert to. ill return an error if the symbol is not supported.
cbconvertCallbackThe calback that will be executed when the request is processed.

Example

currency.convert(10, 'USD', 'EUR', function(err, converted) {
   if (err) // Handle error

   console.log(converted); // Outputs ~8.91 (the converted value)
});

Example

currency.convert([10, 20, 40], 'USD', 'EUR', function(err, converted) {
   if (err) // Handle error

   console.log(converted); // Outputs [9.11, 18.22, 27.33] (the converted values in an array)
});

y-currency.getCurrency(symbols, cb)

Gets currency information as an object or array of objects in one request.

Kind: static method of y-currency

ParamTypeDescription
symbolsstring | Array.<string>A string or array of strings of the pairs to get information on.
cbgetCurrencyCallbackThe calback that will be executed when the request is processed.

Example

currency.getCurrency('USDEUR', function(err, result) {
   if (err) // Handle error

   console.log(result); // Outputs an object with currency information
   
   // Output
   { id: 'USDEUR',
     Name: 'USD to EUR',
     Rate: '0.891',
     Date: '2/27/2015',
     Time: '10:56am',
     Ask: '0.891',
     Bid: '0.8909' }
});

Example

currency.getCurrency(['USDEUR', 'NZDCAD', 'THBSEK'], function(err, result) {
   if (err) // Handle error

   console.log(result); // Outputs an object array with currency information
   
   // Output
   [ { id: 'USDEUR',
      Name: 'USD to EUR',
      Rate: '0.8935',
      Date: '2/27/2015',
      Time: '12:07pm',
      Ask: '0.8935',
      Bid: '0.8935' },
    { id: 'NZDCAD',
      Name: 'NZD to CAD',
      Rate: '0.9452',
      Date: '2/27/2015',
      Time: '12:07pm',
      Ask: '0.9455',
      Bid: '0.9449' },
    { id: 'THBSEK',
      Name: 'THB to SEK',
      Rate: '0.2587',
      Date: '2/27/2015',
      Time: '12:07pm',
      Ask: '0.2592',
      Bid: '0.2581' } ]
});

y-currency~convertCallback : function

Callback that handles the response by convert().

Kind: inner typedef of y-currency

ParamTypeDescription
errerror | nullIf an error occurs during the execution of the function it is passed here, otherwise null.
valuesnumber | Array.<number> | nullIf no errors occured this contains the converted value/values, otherwise null.

y-currency~getCurrencyCallback : function

Callback that handles the response by getCurrency().

Kind: inner typedef of y-currency

ParamTypeDescription
errerror | nullIf an error occurs during the execution of the function it is passed here, otherwise null.
valuesObject | Array.<Object> | nullIf no errors occured this contains the object or object array containing the currency information, otherwise null.

Keywords

FAQs

Last updated on 03 Jan 2016

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