yahoo-exchange
Advanced tools
Comparing version 1.0.0-alpha to 1.0.0-alpha.2
@@ -28,2 +28,11 @@ "use strict"; | ||
exports.getDataArray = getDataArray; | ||
function getPairArray(currency, base) { | ||
let list = []; | ||
currency.forEach(v => base.forEach(v2 => { | ||
if (v2 !== v) | ||
list.push(v + v2); | ||
})); | ||
return list; | ||
} | ||
exports.getPairArray = getPairArray; | ||
//# sourceMappingURL=index.js.map |
10
index.ts
@@ -14,3 +14,3 @@ import request = require("request"); | ||
export function getDataArray(pair: Array<string>, callback: (data: number, pair?: string) => any, errorHandler: (error: Error, pair?: String) => any = err => console.log(err)): void { | ||
pair.map(v => request({ | ||
pair.map(v => request({ | ||
url: `https://finance.yahoo.com/quote/${v}=X?p=${v}=X`, | ||
@@ -22,2 +22,10 @@ encoding: null, | ||
})); | ||
} | ||
export function getPairArray(currency: Array<string>, base: Array<string>): Array<string> { | ||
let list: Array<string> = []; | ||
currency.forEach(v => base.forEach(v2 => { | ||
if (v2 !== v) list.push(v + v2); | ||
})); | ||
return list; | ||
} |
@@ -14,3 +14,3 @@ { | ||
"main": "index.js", | ||
"version": "1.0.0-alpha", | ||
"version": "1.0.0-alpha.2", | ||
"license": "MIT", | ||
@@ -17,0 +17,0 @@ "dependencies": { |
# yahoo-exchange | ||
npm : https://www.npmjs.com/package/yahoo-exchange | ||
## getData(pair, callback, errorHandler): void | ||
@@ -43,2 +44,11 @@ ### Example | ||
getDataArray does not return Array to Callback. | ||
## getPairArray(currency: Array<string>, base: Array<string>): Array<string> | ||
It Returns a pair array. | ||
### Example | ||
* ``` javascript | ||
const currency = ['USD','JPY']; | ||
const base = ['KRW']; | ||
getPairArray(currency,base); | ||
// ['USDKRW','JPYKRW']; | ||
``` | ||
## test.js | ||
@@ -45,0 +55,0 @@ * ``` javascript |
Sorry, the diff of this file is not supported yet
18217
77
62