@effection/events
Advanced tools
Comparing version 2.0.4 to 2.0.5
# Changelog | ||
## \[2.0.5] | ||
### Dependencies | ||
- Updated to latest `@effection/core` | ||
## \[2.0.4] | ||
@@ -4,0 +10,0 @@ |
@@ -11,3 +11,3 @@ /// <reference types="node" /> | ||
*/ | ||
export declare type EventSource = EventEmitterSource | EventTargetSource; | ||
export type EventSource = EventEmitterSource | EventTargetSource; | ||
export declare function addListener<TArgs extends unknown[] = [unknown]>(source: EventSource, name: string, listener: (...args: TArgs) => void): void; | ||
@@ -14,0 +14,0 @@ export declare function removeListener<TArgs extends unknown[] = [unknown]>(source: EventSource, name: string, listener: (...args: TArgs) => void): void; |
@@ -45,4 +45,4 @@ "use strict"; | ||
function on(source, name, streamName = `on('${name}')`) { | ||
return stream_1.createStream((publish) => core_1.withLabels(function* () { | ||
event_source_1.addListener(source, name, publish); | ||
return (0, stream_1.createStream)((publish) => (0, core_1.withLabels)(function* () { | ||
(0, event_source_1.addListener)(source, name, publish); | ||
try { | ||
@@ -52,3 +52,3 @@ yield; | ||
finally { | ||
event_source_1.removeListener(source, name, publish); | ||
(0, event_source_1.removeListener)(source, name, publish); | ||
} | ||
@@ -90,5 +90,5 @@ }, { name: 'listen', eventName: name, source: source.toString() }), streamName); | ||
function onEmit(source, name, streamName = `onEmit('${name}')`) { | ||
return stream_1.createStream((publish) => core_1.withLabels(function* () { | ||
return (0, stream_1.createStream)((publish) => (0, core_1.withLabels)(function* () { | ||
let listener = (...args) => publish(args); | ||
event_source_1.addListener(source, name, listener); | ||
(0, event_source_1.addListener)(source, name, listener); | ||
try { | ||
@@ -98,3 +98,3 @@ yield; | ||
finally { | ||
event_source_1.removeListener(source, name, listener); | ||
(0, event_source_1.removeListener)(source, name, listener); | ||
} | ||
@@ -101,0 +101,0 @@ }, { name: 'listen', eventName: name, source: source.toString() }), streamName); |
@@ -33,7 +33,7 @@ "use strict"; | ||
function once(source, eventName) { | ||
return core_1.withLabels((task) => { | ||
let { future, resolve } = core_1.createFuture(); | ||
return (0, core_1.withLabels)((task) => { | ||
let { future, resolve } = (0, core_1.createFuture)(); | ||
let listener = (...args) => { resolve(args[0]); }; | ||
event_source_1.addListener(source, eventName, listener); | ||
task.consume(() => event_source_1.removeListener(source, eventName, listener)); | ||
(0, event_source_1.addListener)(source, eventName, listener); | ||
task.consume(() => (0, event_source_1.removeListener)(source, eventName, listener)); | ||
return future; | ||
@@ -71,7 +71,7 @@ }, { name: `once`, eventName, source: source.toString() }); | ||
function onceEmit(source, eventName) { | ||
return core_1.withLabels((task) => { | ||
let { future, resolve } = core_1.createFuture(); | ||
return (0, core_1.withLabels)((task) => { | ||
let { future, resolve } = (0, core_1.createFuture)(); | ||
let listener = (...args) => { resolve(args); }; | ||
event_source_1.addListener(source, eventName, listener); | ||
task.consume(() => event_source_1.removeListener(source, eventName, listener)); | ||
(0, event_source_1.addListener)(source, eventName, listener); | ||
task.consume(() => (0, event_source_1.removeListener)(source, eventName, listener)); | ||
return future; | ||
@@ -78,0 +78,0 @@ }, { name: `onceEmit`, eventName, source: source.toString() }); |
@@ -27,3 +27,3 @@ "use strict"; | ||
function* throwOnErrorEvent(source) { | ||
let error = yield once_1.once(source, 'error'); | ||
let error = yield (0, once_1.once)(source, 'error'); | ||
throw error; | ||
@@ -30,0 +30,0 @@ } |
@@ -11,3 +11,3 @@ /// <reference types="node" /> | ||
*/ | ||
export declare type EventSource = EventEmitterSource | EventTargetSource; | ||
export type EventSource = EventEmitterSource | EventTargetSource; | ||
export declare function addListener<TArgs extends unknown[] = [unknown]>(source: EventSource, name: string, listener: (...args: TArgs) => void): void; | ||
@@ -14,0 +14,0 @@ export declare function removeListener<TArgs extends unknown[] = [unknown]>(source: EventSource, name: string, listener: (...args: TArgs) => void): void; |
{ | ||
"name": "@effection/events", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "Helpers for listening to events with effection", | ||
@@ -31,13 +31,5 @@ "main": "dist-cjs/index.js", | ||
"dependencies": { | ||
"@effection/core": "2.2.1", | ||
"@effection/stream": "2.0.4" | ||
"@effection/core": "2.2.2", | ||
"@effection/stream": "2.0.5" | ||
}, | ||
"devDependencies": { | ||
"@frontside/tsconfig": "^1.2.0", | ||
"@types/node": "16.3.2", | ||
"expect": "^25.4.0", | ||
"mocha": "^8.3.1", | ||
"ts-node": "^10.4.0", | ||
"typescript": "4.3.5" | ||
}, | ||
"volta": { | ||
@@ -44,0 +36,0 @@ "extends": "../../package.json" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70208
0
+ Added@chainsafe/abort-controller@3.0.1(transitive)
+ Added@effection/core@2.2.2(transitive)
+ Added@effection/stream@2.0.5(transitive)
+ Added@effection/subscription@2.0.5(transitive)
- Removed@effection/core@2.2.1(transitive)
- Removed@effection/stream@2.0.4(transitive)
- Removed@effection/subscription@2.0.4(transitive)
- Removedabort-controller@3.0.0(transitive)
Updated@effection/core@2.2.2
Updated@effection/stream@2.0.5