cbr-rates-cli
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -20,2 +20,6 @@ #!/usr/bin/env node | ||
var _indentString = require('indent-string'); | ||
var _indentString2 = _interopRequireDefault(_indentString); | ||
var _meow = require('meow'); | ||
@@ -46,9 +50,19 @@ | ||
if (err) return; | ||
var values = []; | ||
(0, _ea2['default'])(rates, function (_ref, id) { | ||
var par = _ref.par; | ||
(0, _ea2['default'])(rates, function (_ref) { | ||
var value = _ref.value; | ||
values.push(value); | ||
}); | ||
var length = integerLength(Math.max.apply(Math, values)); | ||
(0, _ea2['default'])(rates, function (_ref2, id) { | ||
var par = _ref2.par; | ||
var value = _ref2.value; | ||
var indent = length - integerLength(value); | ||
id = id.toUpperCase(); | ||
value = value.toFixed(4); | ||
value = (0, _indentString2['default'])(value.toFixed(2), ' ', indent); | ||
console.log(id + ' ' + _chalk2['default'].bold(value) + ' ' + _chalk2['default'].grey(par)); | ||
@@ -58,1 +72,5 @@ }); | ||
function integerLength(num) { | ||
return num.toFixed().toString().length; | ||
} | ||
15
cli.js
@@ -5,2 +5,3 @@ #!/usr/bin/env node | ||
import each from 'ea'; | ||
import indentString from 'indent-string'; | ||
import meow from 'meow'; | ||
@@ -29,8 +30,20 @@ | ||
if (err) return; | ||
const values = []; | ||
each(rates, ({value}) => { | ||
values.push(value); | ||
}); | ||
const length = integerLength(Math.max(...values)); | ||
each(rates, ({par, value}, id) => { | ||
const indent = length - integerLength(value); | ||
id = id.toUpperCase(); | ||
value = value.toFixed(4); | ||
value = indentString(value.toFixed(2), ' ', indent); | ||
console.log(`${id} ${chalk.bold(value)} ${chalk.grey(par)}`); | ||
}); | ||
}); | ||
function integerLength(num) { | ||
return num.toFixed().toString().length; | ||
} |
{ | ||
"name": "cbr-rates-cli", | ||
"description": "Get currency rates from Central Bank of Russia", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"keywords": [ | ||
@@ -18,2 +18,3 @@ "cbr", | ||
"ea": "^0.5.0", | ||
"indent-string": "^2.1.0", | ||
"meow": "^3.3.0" | ||
@@ -32,4 +33,4 @@ }, | ||
}, | ||
"author": "Andrey Polischuk <andre.polischuk@gmail.com> (https://twitter.com/andrepolischuk)", | ||
"author": "Andrey Polischuk <andre.polischuk@gmail.com>", | ||
"license": "MIT" | ||
} |
# cbr-rates-cli | ||
> Get currency rates from Central Bank of Russia | ||
> Get currency rates from Central Bank of Russia | ||
[cbr-rates][cbr-rates] - API for this module | ||
[cbr-rates][cbr-rates] - API for this module | ||
```sh | ||
cbr-rates | ||
AMD 13.3833 100 | ||
AUD 47.0135 1 | ||
AZN 61.0384 1 | ||
BGN 36.3857 1 | ||
BRL 18.4122 1 | ||
BYR 40.0618 10000 | ||
CAD 49.2374 1 | ||
CHF 65.5121 1 | ||
CNY 10.0025 1 | ||
CZK 26.3402 10 | ||
DKK 95.3754 10 | ||
EUR 71.1475 1 | ||
GBP 99.9597 1 | ||
AMD 13.38 100 | ||
AUD 47.01 1 | ||
AZN 61.03 1 | ||
BGN 36.38 1 | ||
BRL 18.41 1 | ||
BYR 40.06 10000 | ||
CAD 49.23 1 | ||
CHF 65.51 1 | ||
CNY 10.00 1 | ||
CZK 26.34 10 | ||
DKK 95.37 10 | ||
EUR 71.14 1 | ||
GBP 99.95 1 | ||
... | ||
USD 63.9988 1 | ||
UZS 24.7769 1000 | ||
XDR 89.7071 1 | ||
ZAR 50.0534 10 | ||
USD 63.99 1 | ||
UZS 24.77 1000 | ||
XDR 89.70 1 | ||
ZAR 50.05 10 | ||
``` | ||
@@ -51,4 +51,4 @@ | ||
MIT | ||
MIT | ||
[cbr-rates]: https://github.com/andrepolischuk/cbr-rates |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5043
88
5
+ Addedindent-string@^2.1.0