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

twitchrequest

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twitchrequest - npm Package Compare versions

Comparing version 1.4.7 to 1.4.8

71

index.js

@@ -55,2 +55,8 @@ "use strict";

var constants_1 = require("./util/constants");
var isEmpty = function (str) {
return (str == "" || str == null || str == undefined || str.length == 0 || str.trim().length == 0 || str.trim() == "");
};
var isNotEmpty = function (response) {
return (response && response.data && response.data.length);
};
var Client = /** @class */ (function (_super) {

@@ -253,3 +259,3 @@ __extends(Client, _super);

response = _a.sent();
if (!response || !response.data) {
if (!isNotEmpty(response)) {
resolve(undefined);

@@ -298,3 +304,3 @@ }

response = _a.sent();
if (!response || !response.data) {
if (!isNotEmpty(response)) {
resolve(undefined);

@@ -377,3 +383,3 @@ }

response = _b.sent();
if (!(response && response.data)) return [3 /*break*/, 9];
if (!isNotEmpty(response)) return [3 /*break*/, 9];
_i = 0, _a = response.data;

@@ -425,3 +431,3 @@ _b.label = 4;

case 0:
_a.trys.push([0, 8, , 9]);
_a.trys.push([0, 6, , 7]);
return [4 /*yield*/, this.getToken()];

@@ -433,10 +439,14 @@ case 1:

response = _a.sent();
if (!(response && response.data)) return [3 /*break*/, 6];
e = response.data[0];
if (!e) return [3 /*break*/, 4];
if (!isNotEmpty(response)) return [3 /*break*/, 4];
e = response.data.find(function (d) { return d.user_id === id; });
return [4 /*yield*/, this.resolveID(id)];
case 3:
userData = _a.sent();
stream = new StreamData(e, e.user_name, e.title, e.game_name, userData.profile, e.thumbnail_url.replace('{width}', '440').replace('{height}', '248') + "?r=" + Math.floor(Math.random() * 999999), e.viewer_count, userData);
resolve(stream);
if (e && userData) {
stream = new StreamData(e, e.user_name, e.title, e.game_name, userData.profile, e.thumbnail_url.replace('{width}', '440').replace('{height}', '248') + "?r=" + Math.floor(Math.random() * 999999), e.viewer_count, userData);
resolve(stream);
}
else {
resolve(undefined);
}
return [3 /*break*/, 5];

@@ -448,11 +458,7 @@ case 4:

case 6:
resolve(undefined);
_a.label = 7;
case 7: return [3 /*break*/, 9];
case 8:
err_5 = _a.sent();
console.log(err_5);
reject(err_5);
return [3 /*break*/, 9];
case 9: return [2 /*return*/];
return [3 /*break*/, 7];
case 7: return [2 /*return*/];
}

@@ -480,34 +486,30 @@ });

case 2:
_a.trys.push([2, 10, , 11]);
return [4 /*yield*/, this.getData("https://api.twitch.tv/helix/streams?user_login=" + username.toLowerCase(), token)];
_a.trys.push([2, 9, , 10]);
return [4 /*yield*/, this.getData("https://api.twitch.tv/helix/streams?user_login=" + username, token)];
case 3:
response = _a.sent();
if (!(response.data === undefined)) return [3 /*break*/, 4];
if (!!isNotEmpty(response)) return [3 /*break*/, 4];
resolve(undefined);
return [3 /*break*/, 9];
return [3 /*break*/, 8];
case 4:
if (!(response.data.length === 0)) return [3 /*break*/, 5];
resolve(undefined);
return [3 /*break*/, 9];
case 5:
e = response.data.find(function (d) { return d.user_name.toLowerCase() === username.toLowerCase(); });
if (!!e) return [3 /*break*/, 6];
if (!!e) return [3 /*break*/, 5];
resolve(undefined);
return [3 /*break*/, 9];
case 6: return [4 /*yield*/, this.getData("https://api.twitch.tv/helix/search/channels?query=" + username.toLowerCase(), token)];
case 7:
return [3 /*break*/, 8];
case 5: return [4 /*yield*/, this.getData("https://api.twitch.tv/helix/search/channels?query=" + username, token)];
case 6:
res = _a.sent();
ee = res.data.find(function (d) { return d.display_name.toLowerCase() === username.toLowerCase(); });
return [4 /*yield*/, this.getUser(username.toLowerCase())];
case 8:
case 7:
userData = _a.sent();
stream = new StreamData(e, e.user_name, e.title, e.game_name, ee.thumbnail_url, e.thumbnail_url.replace('{width}', '440').replace('{height}', '248') + "?r=" + Math.floor(Math.random() * 9999999), e.viewer_count, userData);
resolve(stream);
_a.label = 9;
case 9: return [3 /*break*/, 11];
case 10:
_a.label = 8;
case 8: return [3 /*break*/, 10];
case 9:
err_6 = _a.sent();
console.log(err_6);
return [3 /*break*/, 11];
case 11: return [2 /*return*/];
return [3 /*break*/, 10];
case 10: return [2 /*return*/];
}

@@ -851,5 +853,2 @@ });

}());
var isEmpty = function (str) {
return (str == "" || str == null || str == undefined || str.length == 0 || str.trim().length == 0 || str.trim() == "");
};
module.exports = {

@@ -856,0 +855,0 @@ Client: Client,

{
"name": "twitchrequest",
"version": "1.4.7",
"version": "1.4.8",
"description": "Get Twitch requests for streams, especially when a stream goes live or stops streaming",

@@ -5,0 +5,0 @@ "main": "index.js",

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