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

ecb-euro-exchange-rates

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ecb-euro-exchange-rates - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

5

CHANGELOG.md

@@ -7,2 +7,6 @@ # Changelog

## [1.1.1] - 2018-10-26
### Fixed
- Fixes previous release, which didn’t contain the built files
## [1.1.0] - 2018-10-26

@@ -13,2 +17,3 @@ ### Added

[1.1.1]: https://github.com/qqilihq/ecb-euro-exchange-rates/compare/v1.1.0...v1.1.1
[1.1.0]: https://github.com/qqilihq/ecb-euro-exchange-rates/compare/v1.0.1...v1.1.0

2

dist/index.d.ts

@@ -40,1 +40,3 @@ export interface IExchangeRates {

export declare function fetch(): Promise<IExchangeRateResult>;
export declare function fetchHistoric(): Promise<IExchangeRateResult[]>;
export declare function fetchHistoric90d(): Promise<IExchangeRateResult[]>;

42

dist/index.js

@@ -17,9 +17,33 @@ "use strict";

const result = yield request('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml').promise();
return new Promise((resolve, reject) => {
xml2js.parseString(result, (err, data) => {
if (err)
return reject(err);
const time = data['gesmes:Envelope']['Cube'][0]['Cube'][0]['$']['time'];
const rates = yield parse(result);
if (rates.length !== 1) {
throw new Error(`Expected result to contain one single entry, but got ${rates.length}`);
}
return rates[0];
});
}
exports.fetch = fetch;
function fetchHistoric() {
return __awaiter(this, void 0, void 0, function* () {
return parse(yield request('https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml').promise());
});
}
exports.fetchHistoric = fetchHistoric;
function fetchHistoric90d() {
return __awaiter(this, void 0, void 0, function* () {
return parse(yield request('https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml').promise());
});
}
exports.fetchHistoric90d = fetchHistoric90d;
function parse(result) {
return new Promise((resolve, reject) => {
xml2js.parseString(result, (err, data) => {
if (err)
return reject(err);
const result = [];
const entries = data['gesmes:Envelope']['Cube'][0]['Cube'];
for (const current of entries) {
const time = current['$']['time'];
const rates = {};
for (const item of data['gesmes:Envelope']['Cube'][0]['Cube'][0]['Cube']) {
for (const item of current['Cube']) {
const currency = item['$']['currency'];

@@ -29,8 +53,8 @@ const rate = parseFloat(item['$']['rate']);

}
resolve({ time, rates });
});
result.push({ time, rates });
}
resolve(result);
});
});
}
exports.fetch = fetch;
// CLI only when module is not require'd

@@ -37,0 +61,0 @@ if (require.main === module) {

@@ -5,3 +5,3 @@ {

"author": "Philipp Katz <philipp@philippkatz.de>",
"version": "1.1.0",
"version": "1.1.1",
"main": "dist/index.js",

@@ -29,3 +29,4 @@ "types": "dist/index.d.ts",

"test:coverage": "nyc mocha",
"clean": "rimraf ./.nyc_output ./coverage ./dist"
"clean": "rimraf ./.nyc_output ./coverage ./dist",
"preversion": "run-s clean lint test build"
},

@@ -45,2 +46,3 @@ "dependencies": {

"mocha-junit-reporter": "^1.17.0",
"npm-run-all": "^4.1.3",
"nyc": "^12.0.2",

@@ -47,0 +49,0 @@ "ts-node": "^6.1.1",

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