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

stock-info

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stock-info - npm Package Compare versions

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"
}
}
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