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

twitchonlinetracker

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twitchonlinetracker - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

lib/package.json
{
"name": "twitchonlinetracker",
"version": "1.1.0",
"version": "1.1.1",
"description": "A library to help track streamers and fires an event if they go online.",

@@ -5,0 +5,0 @@ "main": "lib/",

@@ -98,2 +98,9 @@ /// <reference types="node" />

_announce(streamData: StreamData): void;
/**
* Emit an event when a stream stops
* @fires TwitchOnlineTracker#offline
* @param {string} channelName the channel name of the stream that has stopped
* @memberof TwitchOnlineTracker
*/
_offline(channelName: string): void;
}

@@ -284,3 +284,3 @@ 'use strict';

return __awaiter(this, void 0, void 0, function () {
var _streamDataJson, streamRequestData, started, e_3;
var _streamDataJson, streamRequestData_1, started, stopped, e_3;
var _this = this;

@@ -295,4 +295,4 @@ return __generator(this, function (_a) {

_streamDataJson = _a.sent();
streamRequestData = _streamDataJson;
started = streamRequestData.data
streamRequestData_1 = _streamDataJson;
started = streamRequestData_1.data
.filter(function (current) {

@@ -303,5 +303,17 @@ return _this._cachedStreamData.filter(function (other) {

});
if (started.length)
stopped = this._cachedStreamData
.filter(function (current) {
return streamRequestData_1.data.filter(function (other) {
return other.user_name === current.user_name;
}).length == 0;
});
if (started.length) {
this.log(started.length + " new streams");
this._cachedStreamData = streamRequestData.data;
started.forEach(function (startedStream) { return _this._announce(startedStream); });
}
if (stopped.length) {
this.log(stopped.length + " stopped streams");
stopped.forEach(function (stoppedStream) { return _this._offline(stoppedStream.user_name); });
}
this._cachedStreamData = streamRequestData_1.data;
return [2 /*return*/, started];

@@ -333,8 +345,21 @@ case 2: return [3 /*break*/, 4];

* @event TwitchOnlineTracker#live
* @param {StreamData} channel The stream that has started
* @param {StreamData} The stream that has started
*/
this.emit('live', streamData);
};
/**
* Emit an event when a stream stops
* @fires TwitchOnlineTracker#offline
* @param {string} channelName the channel name of the stream that has stopped
* @memberof TwitchOnlineTracker
*/
TwitchOnlineTracker.prototype._offline = function (channelName) {
/**
* @event TwitchOnlineTracker#offline
* @param {string} The stream that has stopped
*/
this.emit('offline', channelName);
};
return TwitchOnlineTracker;
}(EventEmitter));
exports.TwitchOnlineTracker = TwitchOnlineTracker;
{
"name": "twitchonlinetracker",
"version": "1.1.0",
"version": "1.1.1",
"description": "A library to help track streamers and fires an event if they go online.",

@@ -5,0 +5,0 @@ "main": "lib/",

@@ -244,5 +244,20 @@ 'use strict'

})
const stopped = this._cachedStreamData
.filter((current) => {
return streamRequestData.data.filter((other) => {
return other.user_name === current.user_name
}).length == 0;
})
if (started.length) this.log(`${started.length} new streams`)
if (started.length) {
this.log(`${started.length} new streams`)
started.forEach(startedStream => this._announce(startedStream))
}
if (stopped.length) {
this.log(`${stopped.length} stopped streams`)
stopped.forEach(stoppedStream => this._offline(stoppedStream.user_name))
}
this._cachedStreamData = streamRequestData.data

@@ -271,6 +286,20 @@

* @event TwitchOnlineTracker#live
* @param {StreamData} channel The stream that has started
* @param {StreamData} The stream that has started
*/
this.emit('live', streamData)
}
/**
* Emit an event when a stream stops
* @fires TwitchOnlineTracker#offline
* @param {string} channelName the channel name of the stream that has stopped
* @memberof TwitchOnlineTracker
*/
_offline (channelName: string) {
/**
* @event TwitchOnlineTracker#offline
* @param {string} The stream that has stopped
*/
this.emit('offline', channelName)
}
}
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