stock-info
Advanced tools
Comparing version 1.2.0 to 1.3.0
53
index.js
const axios = require('axios'); | ||
const getSingleStockInfo = stock => | ||
new Promise((resolve, reject) => { | ||
if (!stock) { | ||
return reject(Error('Stock symbol required')); | ||
} | ||
if (typeof stock !== 'string') { | ||
return reject(Error(`Invalid argument type. Required: string. Found: ${typeof stock}`)); | ||
} | ||
const getSingleStockInfo = (stock) => new Promise((resolve, reject) => { | ||
if (!stock) { | ||
return reject(Error('Stock symbol required')); | ||
} | ||
if (typeof stock !== 'string') { | ||
return reject( | ||
Error(`Invalid argument type. Required: string. Found: ${typeof stock}`), | ||
); | ||
} | ||
const url = `https://query1.finance.yahoo.com/v7/finance/quote?symbols=${stock}`; | ||
const url = `https://query1.finance.yahoo.com/v7/finance/quote?symbols=${stock}`; | ||
return axios | ||
.get(url) | ||
.then((res) => { | ||
const { data } = res; | ||
if ( | ||
!data || | ||
!data.quoteResponse || | ||
!data.quoteResponse.result || | ||
data.quoteResponse.result.length === 0 | ||
) { | ||
return reject(new Error(`Error retrieving info for symbol ${stock}`)); | ||
} | ||
return resolve(data.quoteResponse.result[0]); | ||
}) | ||
.catch(err => reject(err)); | ||
}); | ||
return axios | ||
.get(url) | ||
.then((res) => { | ||
const { data } = res; | ||
if ( | ||
!data | ||
|| !data.quoteResponse | ||
|| !data.quoteResponse.result | ||
|| data.quoteResponse.result.length === 0 | ||
) { | ||
return reject(new Error(`Error retrieving info for symbol ${stock}`)); | ||
} | ||
return resolve(data.quoteResponse.result[0]); | ||
}) | ||
.catch((err) => reject(err)); | ||
}); | ||
const getStocksInfo = stockList => new Promise((resolve, reject) => { | ||
const getStocksInfo = (stockList) => new Promise((resolve, reject) => { | ||
if (!stockList) { | ||
@@ -33,0 +34,0 @@ return reject(Error('Stock symbol list required')); |
{ | ||
"name": "stock-info", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Node.js module to retrieve stock information from Yahoo Finance API", | ||
@@ -23,10 +23,10 @@ "main": "index.js", | ||
"devDependencies": { | ||
"eslint": "^7.0.0", | ||
"eslint-config-airbnb-base": "^14.0.0", | ||
"eslint-plugin-import": "^2.20.2", | ||
"mocha": "^7.2.0" | ||
"eslint": "^8.1.0", | ||
"eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-plugin-import": "^2.25.2", | ||
"mocha": "^9.1.3" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.18.1" | ||
"axios": "^0.24.0" | ||
} | ||
} |
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
141
10298
+ Addedaxios@0.24.0(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
- Removedaxios@0.18.1(transitive)
- Removedfollow-redirects@1.5.10(transitive)
- Removedis-buffer@2.0.5(transitive)
Updatedaxios@^0.24.0