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

timeout-refresh

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

timeout-refresh - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

3

browser.js

@@ -8,2 +8,3 @@ module.exports = Timeout

this.context = ctx || null
this.called = false
this._timeout = setTimeout(call, ms, this)

@@ -13,2 +14,3 @@ }

Timeout.prototype.refresh = function () {
if (this.called || this.ontimeout === null) return
clearTimeout(this._timeout)

@@ -24,3 +26,4 @@ this._timeout = setTimeout(call, this.ms, this)

function call (self) {
self.called = true
self.ontimeout.call(self.context)
}

2

package.json
{
"name": "timeout-refresh",
"version": "1.0.2",
"version": "1.0.3",
"description": "Efficiently refresh a timer",

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

@@ -8,2 +8,3 @@ module.exports = Timer

this.context = ctx || null
this.called = false
this._timeout = setTimeout(call, ms, this)

@@ -14,2 +15,3 @@ this._timeout.unref()

Timer.prototype.refresh = function () {
if (this.called || this.ontimeout === null) return
this._timeout.refresh()

@@ -24,3 +26,4 @@ }

function call (self) {
self.called = true
self.ontimeout.call(self.context)
}

@@ -53,2 +53,19 @@ const tape = require('tape')

})
tape(prefix + 'cannot be refreshed after call', function (t) {
t.plan(2)
var timedout = false
const to = timeout(50, function () {
t.notOk(timedout, 'did not already timeout')
t.pass('should be destroyed')
to.refresh()
timedout = true
})
setTimeout(function () {
t.end()
}, 500)
})
}

@@ -14,2 +14,3 @@ var timers = require('timers')

this.context = ctx || null
this.called = false
enroll(this, ms)

@@ -20,2 +21,3 @@ active(this)

Timeout.prototype._onTimeout = function () {
this.called = true
this.ontimeout.call(this.context)

@@ -25,2 +27,3 @@ }

Timeout.prototype.refresh = function () {
if (this.called || this.ontimeout === null) return
active(this)

@@ -27,0 +30,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