New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

polling-to-event

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polling-to-event - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

example/simple.js

22

index.js

@@ -15,4 +15,4 @@ var extend = require("extend"),

var lastParams = undefined;
var _this = this,
lastParams = undefined,
defaults = {

@@ -38,6 +38,5 @@ interval: 1000,

// after the user's wish to pause the event emission.
if (_this.interval.isPaused()) {
return
if (_this.interval && _this.interval.isPaused()) {
return;
}
debug("Emitting '%s'.", options.eventName);
// Save the event name as first item in the parameters array

@@ -49,2 +48,6 @@ // that will be used wit _this.emit.apply()

}
debug("Emitting '%s' with params %j.", options.eventName, params);
// Emit the interval event after every polling
_this.emit.apply(_this, params);
// If long polling is set, compare

@@ -68,7 +71,12 @@ // the last value polled with the last one

}
// Emit the interval event after every polling
return _this.emit.apply(_this, params);
}
// Call the function right away
// inside a timeout with 0 in order for the user to be able
// to set handlers for the first poll intuitively after creating a poller
setTimeout(function() {
func(done);
}, 0);
// Set the interval
_this.interval = pauseable.setInterval(function() {

@@ -82,2 +90,4 @@ // Call the user's function only if he has not paused the interval.

}, options.interval);
}

@@ -84,0 +94,0 @@

{
"name": "polling-to-event",
"version": "1.3.0",
"version": "1.4.0",
"description": "Receive events with EventEmitter from a polling function ran on an interval",

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

@@ -75,2 +75,4 @@ # node-polling-to-event

Your polling function will be called right away, and at the end of every interval.
**Arguments**

@@ -112,3 +114,3 @@ * `pollingfunction(done)` - **Required**. The function you want to be called at an interval. When called, this function will receive a `done` parameter as its last argument.

##License
## License

@@ -115,0 +117,0 @@ The MIT License (MIT)

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