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

eventuate

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eventuate - npm Package Compare versions

Comparing version 3.2.0 to 4.0.0

errors.js

7

index.js
var copy = require('shallow-copy'),
assign = require('object-assign')
assign = require('object-assign'),
errors = require('./errors')

@@ -28,3 +29,3 @@ module.exports = function mkEventuate (options) {

if (options.requireConsumption && !eventuate.hasConsumer)
throw ((data instanceof Error) ? data : assign(new Error('Unconsumed eventuate'), { data: data }))
throw ((data instanceof Error) ? data : new UnconsumedEventError('Unconsumed event', { data: data }))
consumers.forEach(function eventuateConsume (consume) {

@@ -52,1 +53,3 @@ consume(data)

}
var UnconsumedEventError = errors.UnconsumedEventError
{
"name": "eventuate",
"version": "3.2.0",
"version": "4.0.0",
"description": "Handle events without emitters",

@@ -40,2 +40,3 @@ "main": "index.js",

"dependencies": {
"define-error": "~1.0.0",
"object-assign": "~3.0.0",

@@ -42,0 +43,0 @@ "shallow-copy": "0.0.1"

@@ -61,3 +61,3 @@ # eventuate

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.
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.

@@ -120,3 +120,7 @@ ### event.removeConsumer(consumer)

### var UnconsumedEventError = require('eventuate/errors').UnconsumedEventError
Constructor of error potentially thrown on eventuates with `requireConsumption` set.
## unmonitored eventuate

@@ -123,0 +127,0 @@

var test = require('tape'),
eventuate = require('..')
eventuate = require('..'),
errors = require('../errors')

@@ -20,1 +21,15 @@ test('eventuate requiring consumption', function (t) {

})
test('should throw UnconsumedEventError when unconsumed data is produced (with requireConsumption set)', function (t) {
t.plan(3)
var error = eventuate({ requireConsumption: true })
try {
error.produce('explode')
}
catch (err) {
t.ok(err instanceof errors.UnconsumedEventError, 'err is instanceof UnconsumedEventError')
t.equal(err.message, 'Unconsumed event', 'message is Unconsumed event')
t.equal(err.data, 'explode', 'data is produced data')
}
})

Sorry, the diff of this file is not supported yet

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