npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

y-currency

v1.0.3

Published

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

Downloads

56

Readme

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.

| Param | Type | Description | | --- | --- | --- | | values | number | Array.<number> | A string or array of strings of the amounts to convert. | | from | string | The currency symbol to convert from. Will return an error if the symbol is not supported. | | to | string | The currency symbol to convert to. ill return an error if the symbol is not supported. | | cb | convertCallback | The 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

| Param | Type | Description | | --- | --- | --- | | symbols | string | Array.<string> | A string or array of strings of the pairs to get information on. | | cb | getCurrencyCallback | The 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

| Param | Type | Description | | --- | --- | --- | | err | error | null | If an error occurs during the execution of the function it is passed here, otherwise null. | | values | number | Array.<number> | null | If 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

| Param | Type | Description | | --- | --- | --- | | err | error | null | If an error occurs during the execution of the function it is passed here, otherwise null. | | values | Object | Array.<Object> | null | If no errors occured this contains the object or object array containing the currency information, otherwise null. |