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

scores

Package Overview
Dependencies
Maintainers
1
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 3.9.2 to 3.9.3

19

lib/parse.js

@@ -8,2 +8,4 @@ 'use strict'

const LENGTH_COEFFICIENT = 2.5
const STATES = {

@@ -86,10 +88,11 @@ PRE: 'pre',

// If no options were supplied then return the time left on the clock
// which could be too early, but its better to err on checking again quickly than not
if (!finalPeriod || !periodLength || period >= finalPeriod) {
return clock
}
// Either no options or game is in overtime so dont add any future time on
// Or find the clock time for all scheduled future periods
const futurePeriodClock = !finalPeriod || !periodLength || period >= finalPeriod
? 0
: (finalPeriod - period) * periodLength
// Otherwise multiply by the number of periods left
return ((finalPeriod - period) * periodLength) + clock
// Use a coefficient to increase make game time a little closer to real time
// whatever number is down here is close enough. it might change
return (clock + futurePeriodClock) * LENGTH_COEFFICIENT
}

@@ -117,3 +120,3 @@

timeRemaining: state === 'in' ? parseTime(parseTimeRemaining(s)) : null,
timeUntil: state === 'pre' ? parseTime(moment(s.date).diff(moment(__now || void 0))) : null
timeUntil: state === 'pre' ? parseTime(moment(s.date).diff(moment(__now || void 0))) + parseTime(parseTimeRemaining(s)) : null
}

@@ -120,0 +123,0 @@ }

{
"name": "scores",
"description": "Track the completion of sports games from a URL.",
"version": "3.9.2",
"version": "3.9.3",
"author": "Luke Karrys <luke@lukekarrys.com>",

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

@@ -26,6 +26,6 @@ /* eslint no-magic-numbers:0 */

t.equal(progress[0].status.timeUntil, null)
t.equal(progress[0].status.timeRemaining, ms('542s'))
t.equal(progress[0].status.timeRemaining, ms('542s') * utils.LENGTH_COEFFICIENT)
t.equal(progress[1].status.timeUntil, null)
t.equal(progress[1].status.timeRemaining, ms('983s'))
t.equal(progress[1].status.timeRemaining, ms('983s') * utils.LENGTH_COEFFICIENT)

@@ -54,6 +54,6 @@ t.end()

t.equal(progress[0].status.timeUntil, null)
t.equal(progress[0].status.timeRemaining, ms('542s'))
t.equal(progress[0].status.timeRemaining, ms('542s') * utils.LENGTH_COEFFICIENT)
t.equal(progress[1].status.timeUntil, null)
t.equal(progress[1].status.timeRemaining, ms(`${983 + (20 * 60)}s`))
t.equal(progress[1].status.timeRemaining, ms(`${983 + (20 * 60)}s`) * utils.LENGTH_COEFFICIENT)

@@ -60,0 +60,0 @@ t.end()

@@ -44,3 +44,3 @@ /* eslint no-magic-numbers:0 */

t.equal(progress[2].status.timeUntil, null)
t.equal(progress[2].status.timeRemaining, ms('20m'))
t.equal(progress[2].status.timeRemaining, ms('20m') * utils.LENGTH_COEFFICIENT)

@@ -47,0 +47,0 @@ t.end()

@@ -37,3 +37,3 @@ /* eslint no-magic-numbers:0 */

t.equal(events.find(OT_GAME).status.timeRemaining, ms('219s'))
t.equal(events.find(OT_GAME).status.timeRemaining, ms('219s') * utils.LENGTH_COEFFICIENT)

@@ -40,0 +40,0 @@ t.end()

@@ -9,5 +9,11 @@ /* eslint no-magic-numbers:0 */

const PERIOD_LENGTH = '20m'
const FINAL_PERIOD = 2
const GAME_LENGTH = ms(PERIOD_LENGTH) * FINAL_PERIOD
test('scheduled games for the next day', (t) => {
const options = {
__now: '2016-03-09T21:00:00-0500'
__now: '2016-03-09T21:00:00-0500',
periodLength: PERIOD_LENGTH,
finalPeriod: FINAL_PERIOD
}

@@ -24,6 +30,6 @@

t.equal(events[0].status.timeUntil, ms('15h'))
t.equal(events[1].status.timeUntil, ms('15h'))
t.equal(events[2].status.timeUntil, ms('15h'))
t.equal(events[3].status.timeUntil, ms('15.5h'))
t.equal(events[0].status.timeUntil, ms('15h') + (GAME_LENGTH * utils.LENGTH_COEFFICIENT))
t.equal(events[1].status.timeUntil, ms('15h') + (GAME_LENGTH * utils.LENGTH_COEFFICIENT))
t.equal(events[2].status.timeUntil, ms('15h') + (GAME_LENGTH * utils.LENGTH_COEFFICIENT))
t.equal(events[3].status.timeUntil, ms('15.5h') + (GAME_LENGTH * utils.LENGTH_COEFFICIENT))

@@ -36,3 +42,5 @@ t.end()

const options = {
__now: '2016-03-10T12:15:00-0500'
__now: '2016-03-10T12:15:00-0500',
periodLength: PERIOD_LENGTH,
finalPeriod: FINAL_PERIOD
}

@@ -43,6 +51,6 @@

t.equal(events[0].status.timeUntil, 0)
t.equal(events[1].status.timeUntil, 0)
t.equal(events[2].status.timeUntil, 0)
t.equal(events[3].status.timeUntil, ms('15m'))
t.equal(events[0].status.timeUntil, GAME_LENGTH * utils.LENGTH_COEFFICIENT)
t.equal(events[1].status.timeUntil, GAME_LENGTH * utils.LENGTH_COEFFICIENT)
t.equal(events[2].status.timeUntil, GAME_LENGTH * utils.LENGTH_COEFFICIENT)
t.equal(events[3].status.timeUntil, ms('15m') + (GAME_LENGTH * utils.LENGTH_COEFFICIENT))

@@ -49,0 +57,0 @@ t.end()

@@ -18,2 +18,3 @@ 'use strict'

module.exports = {
LENGTH_COEFFICIENT: 2.5,
complete,

@@ -20,0 +21,0 @@ seriesComplete,

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