Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Handle events without emitters. If we had to do it all over again, we might do it this way...
var eventuate = require('eventuate'),
assert = require('assert')
// create an event type, let us call it request
// kind of like an EventEmitter for a single event type
var request = eventuate()
// consume all requests (think .on)
function onRequest (req) {
// do something
}
request(onRequest)
// make sure someone is listening
assert(request.hasConsumer)
// produce an event
request.produce({ url: '/test' })
// remove our consumer
request.removeConsumer(onRequest)
See example/compare.js for more compare/contrast between eventuate
and EventEmitter
.
var eventuate = require('eventuate')
Create an object, event
, that represents a consumable event type.
Valid options are:
true
] true
or false
, see "unmonitored eventuate" belowConsume events with the consumer
function, which should have the signature function (data) {}
. When an event is produced, it will be passed to the consumer function as the first and only argument.
Alias for event(consumer)
as described above.
Produce an event. All event
consumer functions will be called with data
. If the requireConsumption
option was provided, and nothing consumes the data, an error will be thrown. In this case, if the data being produced is an instanceof Error
, it will be thrown directly, otherwise an UnconsumedEventError
(see below) will be thrown, and the data that was produced will be attached to the error as a data
property.
Remove the formerly added consumer
, so that it will not be called with future produced events.
Remove all consumers from the eventuate event
.
Property containing value true
or false
, indicating whether or not the event has a consumer.
Property exposing a shallow copy of all consuming functions.
Unmonitored eventuate representing additions of consumers. Any consumers of consumerAdded
will be invoked with the consumer added to the eventuate
.
Example:
var event = eventuate()
event.consumerAdded(function (eventConsumer) {
// eventConsumer will be the consumer function
console.log('a consumer was added to event')
})
Unmonitored eventuate representing removal of consumers. Any consumers of consumerRemoved
will be invoked with the consumer removed from the eventuate
.
Example:
var event = eventuate()
event.consumerRemoved(function (eventConsumer) {
// eventConsumer will be the consumer function
console.log('a consumer was removed from event')
})
Exposes the factory function used to create the eventuate. Example:
var eventuate = require('eventuate'),
assert = require('assert')
var event = eventuate()
assert(event.factory === eventuate)
Return a new eventuate which is a filtered subset of event
. See
eventuate-filter.
Return a new eventuate which produces transformed data of event
. See
eventuate-map.
Return a new eventuate which produces on-goin reduced data of event
. See
eventuate-reduce.
Constructor of error potentially thrown on eventuates with requireConsumption
set.
If the eventuate is created with the option monitorConsumers
set to false, the eventuate will not have the following properties: consumers
, hasConsumer
, consumerRemoved
, consumerAdded
. No events will be triggered when consumers are manipulated. This is used internally within eventuate for sub-events such as consumerRemoved
and consumerAdded
.
The following modules support and extend the functionality of eventuate:
npm install eventuate
npm test [--dot | --spec] [--phantom] [--grep=pattern]
Specifying --dot
or --spec
will change the output from the default TAP style.
Specifying --phantom
will cause the tests to run in the headless phantom browser instead of node.
Specifying --grep
will only run the test files that match the given pattern.
npm run browser-test
This will run the tests in all browsers (specified in .zuul.yml). Be sure to educate zuul first.
npm run coverage [--html]
This will output a textual coverage report. Including --html
will also open
an HTML coverage report in the default browser.
FAQs
Handle events without emitters
The npm package eventuate receives a total of 3,040 weekly downloads. As such, eventuate popularity was classified as popular.
We found that eventuate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.