Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cbr-rates-cli

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cbr-rates-cli - npm Package Compare versions

Comparing version 0.3.0 to 1.0.0

49

index.es5.js

@@ -25,25 +25,33 @@ 'use strict';

var cli = (0, _meow2.default)('\n Usage\n cbr-rates [id] [date]\n\n Examples\n cbr-rates\n cbr-rates usd\n cbr-rates 2014.5.12\n');
var cli = (0, _meow2.default)('\n Usage\n cbr-rates [...id] [date]\n\n Examples\n cbr-rates\n cbr-rates usd eur\n cbr-rates 2014.5.12\n');
var currencyId = cli.input[0];
var dateString = cli.input[1];
var _cli$input$slice = cli.input.slice(-1);
if (/\./.test(currencyId)) {
var _ref = [dateString, currencyId];
currencyId = _ref[0];
dateString = _ref[1];
var _cli$input$slice2 = _slicedToArray(_cli$input$slice, 1);
var last = _cli$input$slice2[0];
var ids = cli.input.map(function (id) {
return id.toLowerCase();
});
var date = undefined;
if (/\./g.test(last)) {
ids = ids.slice(0, -1);
date = parseDateString(last);
}
var date = parseDateString(dateString);
(0, _cbrRates2.default)(date).then(function (rates) {
var _Math;
var values = Object.keys(rates).map(function (id) {
var values = Object.keys(rates).filter(function (id) {
return isIdExist(id, ids);
}).map(function (id) {
return rates[id].value;
});
var length = integerLength((_Math = Math).max.apply(_Math, _toConsumableArray(values)));
Object.keys(rates).forEach(function (id) {
if (currencyId && currencyId !== id) return;
if (!isIdExist(id, ids)) return;
var _rates$id = rates[id];

@@ -54,5 +62,4 @@ var par = _rates$id.par;

var indent = length - integerLength(value);
id = id.toUpperCase();
value = (0, _indentString2.default)(value.toFixed(2), ' ', indent);
console.log(id + ' ' + _chalk2.default.bold(value) + ' ' + _chalk2.default.grey(par));
console.log(id.toUpperCase() + ' ' + _chalk2.default.bold(value) + ' ' + _chalk2.default.grey(par));
});

@@ -62,12 +69,10 @@ });

function parseDateString(str) {
if (!str) return;
var _str$split = str.split('.');
var _dateString$split = dateString.split('.');
var _str$split2 = _slicedToArray(_str$split, 3);
var _dateString$split2 = _slicedToArray(_dateString$split, 3);
var year = _str$split2[0];
var month = _str$split2[1];
var day = _str$split2[2];
var year = _dateString$split2[0];
var month = _dateString$split2[1];
var day = _dateString$split2[2];
return new Date(parseInt(year), parseInt(month) - 1, parseInt(day));

@@ -79,1 +84,5 @@ }

}
function isIdExist(id, ids) {
return !ids.length || ids.indexOf(id) > -1;
}
{
"name": "cbr-rates-cli",
"description": "Get currency rates from Central Bank of Russia",
"version": "0.3.0",
"version": "1.0.0",
"keywords": [

@@ -6,0 +6,0 @@ "cbr",

@@ -21,7 +21,7 @@ # cbr-rates-cli [![Build Status][travis-image]][travis-url]

Usage
cbr-rates [id] [date]
cbr-rates [...id] [date]
Examples
cbr-rates
cbr-rates usd
cbr-rates usd eur
cbr-rates 2014.5.12

@@ -28,0 +28,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc