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

bnr

v1.2.1

Published

Access resources (e.g. exchange rates) provided by the National Bank of Romania.

Downloads

354

Readme

bnr

Version Downloads

Access resources (e.g. exchange rates) provided by the National Bank of Romania.

:cloud: Installation

# Using npm
npm install --save bnr

# Using yarn
yarn add bnr

:clipboard: Example

const bnr = require("bnr");

// Get the currency rates
bnr.getRates((err, rates) => {
    console.log(err || rates);
    // { RON: { multiplier: 1, amount: 1, name: 'RON' },
    //   AED: { amount: 1.1375, name: 'AED', multiplier: 1 },
    //   AUD: { amount: 3.1078, name: 'AUD', multiplier: 1 },
    //   BGN: { amount: 2.3013, name: 'BGN', multiplier: 1 },
    //   BRL: { amount: 1.2211, name: 'BRL', multiplier: 1 },
    //   CAD: { amount: 3.1515, name: 'CAD', multiplier: 1 },
    //   CHF: { amount: 4.1492, name: 'CHF', multiplier: 1 },
    //   CNY: { amount: 0.6073, name: 'CNY', multiplier: 1 },
    //   CZK: { amount: 0.1664, name: 'CZK', multiplier: 1 },
    //   DKK: { amount: 0.605, name: 'DKK', multiplier: 1 },
    //   EGP: { amount: 0.2324, name: 'EGP', multiplier: 1 },
    //   EUR: { amount: 4.5008, name: 'EUR', multiplier: 1 },
    //   GBP: { amount: 5.3302, name: 'GBP', multiplier: 1 },
    //   HRK: { amount: 0.597, name: 'HRK', multiplier: 1 },
    //   HUF: { amount: 1.4308, name: 'HUF', multiplier: 100 },
    //   INR: { amount: 0.0615, name: 'INR', multiplier: 1 },
    //   JPY: { amount: 3.6641, name: 'JPY', multiplier: 100 },
    //   KRW: { amount: 0.357, name: 'KRW', multiplier: 100 },
    //   MDL: { amount: 0.208, name: 'MDL', multiplier: 1 },
    //   MXN: { amount: 0.2036, name: 'MXN', multiplier: 1 },
    //   NOK: { amount: 0.5001, name: 'NOK', multiplier: 1 },
    //   NZD: { amount: 2.9782, name: 'NZD', multiplier: 1 },
    //   PLN: { amount: 0.9992, name: 'PLN', multiplier: 1 },
    //   RSD: { amount: 0.0365, name: 'RSD', multiplier: 1 },
    //   RUB: { amount: 0.0655, name: 'RUB', multiplier: 1 },
    //   SEK: { amount: 0.4581, name: 'SEK', multiplier: 1 },
    //   TRY: { amount: 1.1887, name: 'TRY', multiplier: 1 },
    //   UAH: { amount: 0.1602, name: 'UAH', multiplier: 1 },
    //   USD: { amount: 4.1782, name: 'USD', multiplier: 1 },
    //   XAU: { amount: 157.3266, name: 'XAU', multiplier: 1 },
    //   XDR: { amount: 5.6865, name: 'XDR', multiplier: 1 },
    //   ZAR: { amount: 0.3065, name: 'ZAR', multiplier: 1 } }
});

// Convert 100 EUR into USD
bnr.convert(100, "EUR", "USD", function (err, amount, output) {
    if (err) { return console.error(err); }
    console.log(`Result: ${amount}`);
    console.log(`${output.input.amount} ${output.input.currency} is ${output.output.amount} ${output.output.currency}`);
    // Result: 107.72102819395911
    // 100 EUR is 107.72102819395911 USD
});

// The promise way
bnr.getRates().then(console.log)

:question: Get Help

There are few ways to get help:

  1. Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
  2. For bug reports and feature requests, open issues. :bug:

:memo: Documentation

getRates(cb)

Get the currency exchange rates.

Params

  • Function cb: The callback function.

convert(amount, inputCurrency, outputCurrency, cb)

Convert currencies.

Params

  • Number amount: The amount of the input currency.
  • String inputCurrency: The input currency name (e.g. EUR).
  • String outputCurrency: The output currency (e.g. USD).
  • Function cb: The callback function.

:yum: How to contribute

Have an idea? Found a bug? See how to contribute.

:dizzy: Where is this library used?

If you are using this library in one of your projects, add it in this list. :sparkles:

  • bloggify-shop

:scroll: License

MIT © Bloggify