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

scores

Package Overview
Dependencies
Maintainers
2
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scores - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

16

index.js

@@ -58,3 +58,4 @@ var EventEmitter = require('events').EventEmitter,

dailyCutoff: 180,
ignoreInitial: true
ignoreInitial: true,
__now: null
});

@@ -69,2 +70,3 @@

this.lastDate = null;
this.__now = options.__now;

@@ -92,7 +94,8 @@ EventEmitter.call(this);

ScoreTracker.prototype._next = function (interval) {
var m = moment().tz(this.options.timezone);
var m = (this.__now || moment()).tz(this.options.timezone);
if (_.isObject(interval)) {
interval =
m.clone()
.hour(interval.period === 'PM' && interval.hours !== 12 ? interval.hours + 12 : interval.hours).minute(interval.minutes).second(0).millisecond(0)
.hour(interval.period === 'PM' && interval.hours !== 12 ? interval.hours + 12 : interval.hours)
.minute(interval.minutes).second(0).millisecond(0)
.diff(m.clone());

@@ -121,2 +124,7 @@ this.lastInterval = null;

if (interval <= 0) {
interval = ms(this.options.interval);
this.lastInterval = interval;
}
this.currentInterval = interval;

@@ -129,3 +137,3 @@ this.logger.info('[NEXT]', interval + 'ms');

ScoreTracker.prototype.request = function (ignore) {
var date = moment().tz(this.options.timezone).subtract(this.options.dailyCutoff, 'm').format('YYYYMMDD');
var date = (this.__now || moment()).tz(this.options.timezone).subtract(this.options.dailyCutoff, 'm').format('YYYYMMDD');
if (this.lastDate && date !== this.lastDate) {

@@ -132,0 +140,0 @@ // Clear emitted game IDs if we are on a new day

{
"name": "scores",
"description": "Track the completion of sports games from a URL.",
"version": "1.0.5",
"version": "1.0.6",
"author": "Nick Crohn",

@@ -6,0 +6,0 @@ "bugs": {

@@ -141,2 +141,3 @@ var assert = require('assert');

it('It should not fetch until the first game', function () {
var now = moment().hours(12).minutes(0).seconds(0).milliseconds(0);
var s = new ScoreTracker({

@@ -146,11 +147,28 @@ timezone: timezone,

maxInterval: maxInterval,
dailyCutoff: dailyCutoff
dailyCutoff: dailyCutoff,
__now: now.clone()
});
s.parse(fs.readFileSync('./test/data/no-started-games.html'));
var next = moment().tz('America/New_York').add(s.currentInterval, 'ms').format(format);
var expected = moment().tz('America/New_York').hours(19).minutes(0).seconds(0).milliseconds(0).format(format);
var next = now.clone().tz('America/New_York').add(s.currentInterval, 'ms').format(format);
var expected = now.clone().tz('America/New_York').hours(19).minutes(0).seconds(0).milliseconds(0).format(format);
assert.equal(next, expected);
});
it('If the first game is in the past, use normal interval', function () {
var now = moment().hours(9).minutes(16).seconds(0).milliseconds(0);
var s = new ScoreTracker({
timezone: timezone,
interval: interval,
maxInterval: maxInterval,
dailyCutoff: dailyCutoff,
__now: now.clone()
});
s.parse(fs.readFileSync('./test/data/no-started-games-2014-rd1.html'));
var next = now.clone().tz('America/New_York').add(s.currentInterval, 'ms').format(format);
var expected = now.clone().tz('America/New_York').add(interval, 'm').format(format);
assert.equal(next, expected);
});
it('It should not fetch until the first game 12:15pm', function () {
var now = moment().hours(7).minutes(0).seconds(0).milliseconds(0);
var s = new ScoreTracker({

@@ -160,7 +178,8 @@ timezone: timezone,

maxInterval: maxInterval,
dailyCutoff: dailyCutoff
dailyCutoff: dailyCutoff,
__now: now.clone()
});
s.parse(fs.readFileSync('./test/data/no-started-games-2014-rd1.html'));
var next = moment().tz('America/New_York').add(s.currentInterval, 'ms').format(format);
var expected = moment().tz('America/New_York').hours(12).minutes(15).seconds(0).milliseconds(0).format(format);
var next = now.clone().tz('America/New_York').add(s.currentInterval, 'ms').format(format);
var expected = now.clone().tz('America/New_York').hours(12).minutes(15).seconds(0).milliseconds(0).format(format);
assert.equal(next, expected);

@@ -167,0 +186,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