New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

yahoo-exchange

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yahoo-exchange - npm Package Compare versions

Comparing version 0.1.3 to 1.0.0-alpha

8

index.js

@@ -10,5 +10,5 @@ "use strict";

if (err)
errorHandler(err);
errorHandler(err, pair);
else
callback(parseFloat(html.toString().split('react-text: 36 -->')[1].split('<')[0].replace(',', '')));
callback(parseFloat(html.toString().split('react-text: 36 -->')[1].split('<')[0].replace(',', '')), pair);
});

@@ -23,5 +23,5 @@ }

if (err)
errorHandler(err);
errorHandler(err, v);
else
callback(parseFloat(html.toString().split('react-text: 36 -->')[1].split('<')[0].replace(',', '')));
callback(parseFloat(html.toString().split('react-text: 36 -->')[1].split('<')[0].replace(',', '')), v);
}));

@@ -28,0 +28,0 @@ }

import request = require("request");
export function getData(pair: string, callback: (data: number) => any, errorHandler: (error: Error) => any = err => console.log(err)): void {
request({
url: `https://finance.yahoo.com/quote/${pair}=X?p=${pair}=X`,
encoding: null,
}, (err, response, html) => {
if (err) errorHandler(err);
else callback(parseFloat(html.toString().split('react-text: 36 -->')[1].split('<')[0].replace(',', '')));
});
export function getData(pair: string, callback: (data: number, pair?: string) => any, errorHandler: (error: Error, pair?: String) => any = err => console.log(err)): void {
request({
url: `https://finance.yahoo.com/quote/${pair}=X?p=${pair}=X`,
encoding: null,
}, (err, response, html) => {
if (err) errorHandler(err, pair);
else callback(parseFloat(html.toString().split('react-text: 36 -->')[1].split('<')[0].replace(',', '')), pair);
});
}
export function getDataArray(pair: Array<string>, callback: (data: number) => any, errorHandler: (error: Error) => any = err => console.log(err)): void {
pair.map( v=>request({
url: `https://finance.yahoo.com/quote/${v}=X?p=${v}=X`,
encoding: null,
}, (err, response, html) => {
if (err) errorHandler(err);
else callback(parseFloat(html.toString().split('react-text: 36 -->')[1].split('<')[0].replace(',', '')));
}));
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({
url: `https://finance.yahoo.com/quote/${v}=X?p=${v}=X`,
encoding: null,
}, (err, response, html) => {
if (err) errorHandler(err, v);
else callback(parseFloat(html.toString().split('react-text: 36 -->')[1].split('<')[0].replace(',', '')), v);
}));
}

@@ -14,3 +14,3 @@ {

"main": "index.js",
"version": "0.1.3",
"version": "1.0.0-alpha",
"license": "MIT",

@@ -17,0 +17,0 @@ "dependencies": {

@@ -5,12 +5,20 @@ # yahoo-exchange

* ``` javascript
getData('USDKRW', data=>console.log(data)); // 1070
getData('USDKRW', data => console.log(data)); // 1070
```
* ``` javascript
getData('USDKRW', data=>console.log(data), error=>console.log('[Error]' + error));
getData('USDKRW', data => console.log(data), error => console.log('[Error]' + error));
// 1070 or [Error] error message
```
* ``` javascript
getData('USDKRW', (data,pair) => console.log(data,pair), error => console.log('[Error]' + error));
// 1070 USDRKW or [Error] error message
```
* ``` javascript
getData('USDKRW', (data,pair) => console.log(data,pair), (error,pair) => console.log(`[Error:${pair}]${error}`));
// 1070 USDKRW or [Error:USDKRW] error message
```
## getDataArray(pair, callback, errorHandler): void
### Example
* ``` javascript
getDataArray(['USDKRW', 'JPYKRW'], data=>console.log(data));
getDataArray(['USDKRW', 'JPYKRW'], dat a=> console.log(data));
// 1070

@@ -20,6 +28,16 @@ // 970

* ``` javascript
getDataArray(['USDKRW', 'JPYKRW'], data=>console.log(data),error=>console.log('[Error]' + error));
getDataArray(['USDKRW', 'JPYKRW'], data => console.log(data), error => console.log('[Error]' + error));
// 1070 or [Error] error message
// 970 or [Error] error message
```
* ``` javascript
getDataArray(['USDKRW', 'JPYKRW'], (data,pair)=>console.log(data, pair)), error => console.log('[Error]' + error));
// 1070 USDKRW or [Error] error message
// 970 JPYKRW or [Error] error message
```
* ``` javascript
getDataArray(['USDKRW', 'JPYKRW'], (data,pair)=>console.log(data, pair)), (error,pair) => console.log(`[Error:${pair}]${error}`));
// 1070 USDKRW or [Error:USDKRW] error message
// 970 JPYKRW or [Error:JPYKRW] error message
```
### Warning

@@ -30,5 +48,7 @@ getDataArray does not return Array to Callback.

const yahooExchange = require('yahoo-exchange');
yahooExchange.getData('USDKRW', data => console.log(data));
yahooExchange.getDataArray(['USDKRW', 'JPYKRW'], data =>console.log(data));
yahooExchange.getData('USDKRW', (data, pair) => console.log(data, pair));
yahooExchange.getDataArray(['USDKRW', 'JPYKRW'], (data, pair) => console.log(data, pair));
```
const index = require('../index');
index.getData('USDKRW', data => {
console.log(data);
});
index.getDataArray(['USDKRW', 'JPYKRW'], data =>console.log(data));
index.getData('USDKRW', data => console.log(data));
index.getDataArray(['USDKRW', 'JPYKRW'], data => console.log(data));
index.getData('USDKRW', (data, pair) => console.log(data, pair));
index.getDataArray(['USDKRW', 'JPYKRW'], (data, pair) => console.log(data, pair));
index.getData('USDKRW', (data, pair) => console.log(data, pair), (error,pair) => console.log(`[Error] ${pair}\n${error}`));
index.getDataArray(['USDKRW', 'JPYKRW'], (data, pair) => console.log(data, pair), (error,pair) => console.log(`[Error] ${pair}\n${error}`));

Sorry, the diff of this file is not supported yet

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