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

yahoo-fantasy

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yahoo-fantasy - npm Package Compare versions

Comparing version 3.1.2 to 3.2.0

helpers/isEmpty.js

174

collections/transactionsCollection.js

@@ -1,2 +0,3 @@

var transactionHelper = require("../helpers/transactionHelper.js");
const transactionHelper = require("../helpers/transactionHelper.js");
const isEmpty = require("../helpers/isEmpty.js");

@@ -11,6 +12,6 @@ // TODO: https://fantasysports.yahooapis.com/fantasy/v2/league/{league_key}/transactions;types=waiver,pending_trade;team_key={team_key}

fetch(transactionKeys, resources, filters, cb = () => {}) {
var url =
"https://fantasysports.yahooapis.com/fantasy/v2/transactions;transaction_keys=";
let url =
"https://fantasysports.yahooapis.com/fantasy/v2/transactions;transaction_keys=";
if (_.isString(transactionKeys)) {
if ("string" === typeof transactionKeys) {
transactionKeys = [transactionKeys];

@@ -21,4 +22,4 @@ }

if (!_.isEmpty(resources)) {
if (_.isString(resources)) {
if (!isEmpty(resources)) {
if ("string" === typeof resources) {
resources = [resources];

@@ -30,4 +31,4 @@ }

if (!_.isEmpty(filters)) {
_.each(Object.keys(filters), function(key) {
if (!isEmpty(filters)) {
Object.keys(filters).forEach(function(key) {
url += ";" + key + "=" + filters[key];

@@ -39,9 +40,10 @@ });

return this.yf.api(this.yf.GET, url)
return this.yf
.api(this.yf.GET, url)
.then(data => {
const meta = data.fantasy_content;
cb(null, meta);
return meta;
cb(null, meta);
return meta;
})
.catch(e => {
.catch(e => {
cb(e);

@@ -53,6 +55,6 @@ throw e;

leagueFetch = function(leagueKeys, resources, filters, cb = () => {}) {
var url =
"https://fantasysports.yahooapis.com/fantasy/v2/leagues;league_keys=";
let url =
"https://fantasysports.yahooapis.com/fantasy/v2/leagues;league_keys=";
if (_.isString(leagueKeys)) {
if ("string" === typeof leagueKeys) {
leagueKeys = [leagueKeys];

@@ -64,4 +66,4 @@ }

if (!_.isEmpty(resources)) {
if (_.isString(resources)) {
if (!isEmpty(resources)) {
if ("string" === typeof resources) {
resources = [resources];

@@ -73,4 +75,4 @@ }

if (!_.isEmpty(filters)) {
_.each(Object.keys(filters), function(key) {
if (!isEmpty(filters)) {
Object.keys(filters).forEach(function(key) {
url += ";" + key + "=" + filters[key];

@@ -82,9 +84,10 @@ });

return this.yf.api(this.yf.GET, url)
return this.yf
.api(this.yf.GET, url)
.then(meta => {
const meta = data.fantasy_content;
cb(null, meta);
return meta;
cb(null, meta);
return meta;
})
.catch(e => {
.catch(e => {
cb(e);

@@ -96,8 +99,5 @@ throw e;

add_player = function(leagueKey, teamKey, playerKey, cb = () => {}) {
var url =
"https://fantasysports.yahooapis.com/fantasy/v2/league/" +
leagueKey +
"/transactions?format=json";
var xmlData =
" \
const url = `https://fantasysports.yahooapis.com/fantasy/v2/league/${leagueKey}/transactions?format=json`;
const xmlData = ` \
<fantasy_content> \

@@ -107,29 +107,24 @@ <transaction> \

<player> \
<player_key>" +
playerKey +
"</player_key> \
<player_key>${playerKey}</player_key> \
<transaction_data> \
<type>add</type> \
<destination_team_key>" +
teamKey +
"</destination_team_key> \
<destination_team_key>${teamKey}</destination_team_key> \
</transaction_data> \
</player> \
</transaction> \
</fantasy_content>";
</fantasy_content>`;
return this.yf.api(this.yf.POST, url, xmlData)
return this.yf
.api(this.yf.POST, url, xmlData)
.then(data => {
var transactions = data.fantasy_content.league[1].transactions;
transactions = _.filter(transactions, function(p) {
return typeof p === "object";
});
transactions = _.map(transactions, function(p) {
return p.transaction;
});
var transaction = transactions[0];
var meta = transaction[0];
var players = transactionHelper.mapTransactionPlayers(
const transactions = data.fantasy_content.league[1].transactions
.filter(p => typeof p === "object")
.map(({ transaction }) => transaction);
const transaction = transactions[0];
const meta = transaction[0];
const players = transactionHelper.mapTransactionPlayers(
transaction[1].players
);
meta.players = players;

@@ -139,3 +134,3 @@ cb(null, meta);

})
.catch(e => {
.catch(e => {
cb(e);

@@ -147,8 +142,4 @@ throw e;

drop_player = function(leagueKey, teamKey, playerKey, cb = () => {}) {
var url =
"https://fantasysports.yahooapis.com/fantasy/v2/league/" +
leagueKey +
"/transactions?format=json";
var xmlData =
" \
const url = `https://fantasysports.yahooapis.com/fantasy/v2/league/${leagueKey}/transactions?format=json`;
const xmlData = ` \
<fantasy_content> \

@@ -158,27 +149,21 @@ <transaction> \

<player> \
<player_key>" +
playerKey +
"</player_key> \
<player_key>${playerKey}</player_key> \
<transaction_data> \
<type>drop</type> \
<source_team_key>" +
teamKey +
"</source_team_key> \
<source_team_key>${teamKey}</source_team_key> \
</transaction_data> \
</player> \
</transaction> \
</fantasy_content>";
</fantasy_content>`;
return this.yf.api(this.yf.POST, url, xmlData)
return this.yf
.api(this.yf.POST, url, xmlData)
.then(data => {
var transactions = data.fantasy_content.league[1].transactions;
transactions = _.filter(transactions, function(p) {
return typeof p === "object";
});
transactions = _.map(transactions, function(p) {
return p.transaction;
});
var transaction = transactions[0];
var meta = transaction[0];
var players = transactionHelper.mapTransactionPlayers(
const transactions = data.fantasy_content.league[1].transactions
.filter(p => typeof p === "object")
.map(({ transaction }) => transaction);
const transaction = transactions[0];
const meta = transaction[0];
const players = transactionHelper.mapTransactionPlayers(
transaction[1].players

@@ -204,8 +189,4 @@ );

) {
var url =
"https://fantasysports.yahooapis.com/fantasy/v2/league/" +
leagueKey +
"/transactions?format=json";
var xmlData =
" \
const url = `https://fantasysports.yahooapis.com/fantasy/v2/league/${leagueKey}/transactions?format=json`;
const xmlData = ` \
<fantasy_content> \

@@ -216,21 +197,13 @@ <transaction> \

<player> \
<player_key>" +
addPlayerKey +
"</player_key> \
<player_key>${addPlayerKey}</player_key> \
<transaction_data> \
<type>add</type> \
<destination_team_key>" +
teamKey +
"</destination_team_key> \
<destination_team_key>${teamKey}</destination_team_key> \
</transaction_data> \
</player> \
<player> \
<player_key>" +
dropPlayerKey +
"</player_key> \
<player_key>${dropPlayerKey}</player_key> \
<transaction_data> \
<type>drop</type> \
<source_team_key>" +
teamKey +
"</source_team_key> \
<source_team_key>${teamKey}</source_team_key> \
</transaction_data> \

@@ -240,16 +213,13 @@ </player> \

</transaction> \
</fantasy_content>";
</fantasy_content>`;
return this.yf.api(this.yf.POST, url, xmlData)
return this.yf
.api(this.yf.POST, url, xmlData)
.then(data => {
var transactions = data.fantasy_content.league[1].transactions;
transactions = _.filter(transactions, function(p) {
return typeof p === "object";
});
transactions = _.map(transactions, function(p) {
return p.transaction;
});
var transaction = transactions[0];
var meta = transaction[0];
var players = transactionHelper.mapTransactionPlayers(
const transactions = data.fantasy_content.league[1].transactions
.filter(p => typeof p === "object")
.map(({ transaction }) => transaction);
const transaction = transactions[0];
const meta = transaction[0];
const players = transactionHelper.mapTransactionPlayers(
transaction[1].players

@@ -256,0 +226,0 @@ );

@@ -1,3 +0,3 @@

var _ = require('lodash');
var userHelper = require('../helpers/userHelper.js');
const userHelper = require("../helpers/userHelper.js");
const isEmpty = require("../helpers/isEmpty.js");

@@ -14,20 +14,24 @@ import { extractCallback } from "../helpers/argsParser.mjs";

UsersCollection.prototype.fetch = function() {
var subresources = ( arguments.length > 1 ) ? arguments[0] : [];
const cb = extractCallback(args);
let subresources = arguments.length ? arguments[0] : [];
var url = 'https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1';
let url = "https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1";
if ( !( _.isEmpty(subresources) ) ) {
if ( _.isString(subresources) ) {
if (!isEmpty(subresources)) {
if ("string" === typeof subresources) {
subresources = [subresources];
}
url += ';out=' + subresources.join(',');
url += `;out=${subresources.join(",")}`;
}
url += '?format=json';
url += "?format=json";
return this.yf.api(this.yf.GET, url)
return this.yf
.api(this.yf.GET, url)
.then(data => {
const user = userHelper.parseCollection(data.fantasy_content.users[0].user);
const user = userHelper.parseCollection(
data.fantasy_content.users[0].user
);
cb(null, user);

@@ -40,2 +44,2 @@ return user;

});
};
};
{
"name": "yahoo-fantasy",
"version": "3.1.2",
"version": "3.2.0",
"description": "An API to help facilitate the use of the Yahoo! Fantasy Sports API in NodeJS projects.",

@@ -27,10 +27,9 @@ "main": "index.js",

"dependencies": {
"esm": "^3.2.25",
"request": "^2.87.0"
"esm": "^3.2.25"
},
"devDependencies": {
"istanbul": "^0.4.3",
"jasmine": "^3.0.0",
"jasmine": "^3.4.0",
"jasmine-spec-reporter": "^4.2.1",
"nock": "^9.3.0",
"nock": "^9.6.1",
"prettier": "^1.18.2",
"q": "^1.4.1"

@@ -37,0 +36,0 @@ },

@@ -29,5 +29,5 @@ # Yahoo! Fantasy API Node Module

var YahooFantasy = require('yahoo-fantasy');
const YahooFantasy = require('yahoo-fantasy');
// you can get an application key/secret by creating a new application on Yahoo!
var yf = new YahooFantasy(
const yf = new YahooFantasy(
Y!APPLICATION_KEY,

@@ -79,2 +79,9 @@ Y!APPLICATION_SECRET

#### 3.2.0
- Added "players" subresource to "league" in order to obtain weekly / season stats for a player based on league settings
- Fixed a bug where the starting status wasn't properly being returned due to a shift in how the data was being returned
- Removed use of "request" library for size and performance reasons
- General code optimizations and improvements
#### 3.1.2

@@ -81,0 +88,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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