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.4.1 to 2.0.0

4

example/long-polling.js

@@ -14,4 +14,4 @@ var pollingtoevent = require(".."),

emitter.on("update", function(data) {
console.log("Update emitted at %s, with data %j", Date.now(), data);
emitter.on("longpoll", function(data) {
console.log("longpoll emitted at %s, with data %j", Date.now(), data);
});

@@ -18,0 +18,0 @@

@@ -12,3 +12,3 @@ var pollingtoevent = require(".."),

emitter.on("interval", function(data) {
emitter.on("poll", function(data) {
console.log("Event emitted at %s, with data %j", Date.now(), data);

@@ -15,0 +15,0 @@ });

@@ -12,3 +12,3 @@ var pollingtoevent = require(".."),

emitter.on("interval", function(data) {
emitter.on("poll", function(data) {
console.log("Event emitted at %s, with data %j", Date.now(), data);

@@ -15,0 +15,0 @@ });

@@ -13,5 +13,4 @@ var pollingtoemitter = require("..");

poller.on("update", function(data) {
console.log("Current number is :%s", nums[i]);
console.log(data);
poller.on("longpoll", function(data) {
console.log("Current number is :%s", data);
});

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

interval: 1000,
eventName: "interval",
updateEventName: "update",
eventName: "poll",
longpollEventName: "longpoll",
longpolling: false,

@@ -62,5 +62,5 @@ };

debug("Last polled data and previous poll data are not equal.");
debug("Emitting '%s'.", options.updateEventName);
// Emit the update event after longpolling
_this.emit.apply(_this, [options.updateEventName].concat(params))
debug("Emitting '%s'.", options.longpollEventName);
// Emit the longpoll event after longpolling
_this.emit.apply(_this, [options.longpollEventName].concat(params))
} else {

@@ -67,0 +67,0 @@ debug("Last polled data and previous poll data are equal.");

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

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

@@ -22,3 +22,3 @@ # node-polling-to-event

emitter.on("interval", function(data) {
emitter.on("poll", function(data) {
console.log(data);

@@ -45,3 +45,3 @@ });

emitter.on("interval", function(data) {
emitter.on("poll", function(data) {
console.log("Event emitted at %s, with data %j", Date.now(), data);

@@ -56,3 +56,3 @@ });

If you set the option `longpolling:true` the emitter will emit an *update* event when
If you set the option `longpolling:true` the emitter will emit an *longpoll* event when
the polled data differs.

@@ -68,4 +68,4 @@

emitter.on("update", function(data) {
console.log("Update emitted at %s, with data %j", Date.now(), data);
emitter.on("longpoll", function(data) {
console.log("longpoll emitted at %s, with data %j", Date.now(), data);
});

@@ -89,4 +89,4 @@

* `longpolling` - Set to true if you want to be notified when data from the last poll differ from previous polled data. The data taken for comparison is every argument your `pollingfunction` passes to `done()`. The comparison is made with [deep-equal](https://www.npmjs.com/package/deep-equal). **Default:** `false`.
* `eventName` - The event name to emit on each successful call to `done()`. **Default**: `"interval"`.
* `eventUpdateName` - The event name to emit when last polled data differs from previous polling data. **Default**: `"update"`.
* `eventName` - The event name to emit on each successful call to `done()`. **Default**: `"poll"`.
* `longpollEventName` - The event name to emit when last polled data differs from previous polling data. **Default**: `"longpoll"`.

@@ -99,5 +99,5 @@ **Returns**

* `interval` - Emitted when an interval has completed and the `done()` function was called with no errors. *You can also customize this event's name using the option `eventName`*. **Parameters**: Your listener gets the parameter passed to `done()` with exception of the error parameter which is the first parameter `done()` uses.
* `poll` - Emitted when an interval has completed and the `done()` function was called with no errors. *You can also customize this event's name using the option `eventName`*. **Parameters**: Your listener gets the parameter passed to `done()` with exception of the error parameter which is the first parameter `done()` uses.
* `error` - Emitted when `done()` was called with an error object. It emits the data polled by your polling function. **Parameters**. An error object.
* `update` - Emitted when option `longpolling` is true and the last polled data differs from the previous polling data. **Parameters**: Your listener gets the parameter received by `done()` with exception of the error parameter which is the first parameter `done()` uses. *You can also customize this event's name using the option `updateEventName`*
* `longpoll` - Emitted when option `longpolling` is true and the last polled data differs from the previous polling data. **Parameters**: Your listener gets the parameter received by `done()` with exception of the error parameter which is the first parameter `done()` uses. *You can also customize this event's name using the option `longpollEventName`*

@@ -104,0 +104,0 @@ #### Emitter methods

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