@bigtest/effection
Advanced tools
Comparing version 0.1.1-b18ad89 to 0.1.1-bcea1fb
@@ -1,6 +0,3 @@ | ||
export { once } from './events'; | ||
export { Mailbox, SubscriptionMessage, subscribe } from './mailbox'; | ||
export { any } from './pattern'; | ||
export { ensure } from './ensure'; | ||
export { monitorErrors } from './monitor-errors'; | ||
export { Future } from './future'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var events_1 = require("./events"); | ||
exports.once = events_1.once; | ||
var mailbox_1 = require("./mailbox"); | ||
@@ -12,6 +10,2 @@ exports.Mailbox = mailbox_1.Mailbox; | ||
exports.ensure = ensure_1.ensure; | ||
var monitor_errors_1 = require("./monitor-errors"); | ||
exports.monitorErrors = monitor_errors_1.monitorErrors; | ||
var future_1 = require("./future"); | ||
exports.Future = future_1.Future; | ||
//# sourceMappingURL=index.js.map |
@@ -0,4 +1,5 @@ | ||
/// <reference types="node" /> | ||
import { Operation } from 'effection'; | ||
import { EventEmitter } from 'events'; | ||
export { any } from './pattern'; | ||
import { EventSource } from './event-source'; | ||
export interface SubscriptionMessage { | ||
@@ -11,9 +12,9 @@ event: string; | ||
private messages; | ||
static subscribe(source: EventSource, events: string | string[]): Operation<Mailbox<SubscriptionMessage>>; | ||
static subscribe(source: EventEmitter | EventTarget, events: string | string[]): Operation<Mailbox<SubscriptionMessage>>; | ||
setMaxListeners(value: number): void; | ||
send(message: T): void; | ||
receive(pattern?: unknown): Operation<T>; | ||
pipe(other: Mailbox<T>): Generator<Operation<unknown>, any, unknown>; | ||
pipe(other: Mailbox<T>): Generator<Operation<never>, any, unknown>; | ||
map<R>(fn: (from: T) => R): Operation<Mailbox<R>>; | ||
} | ||
export declare function subscribe(mailbox: Mailbox<SubscriptionMessage>, source: EventSource, events: string | string[]): Operation; | ||
export declare function subscribe(mailbox: Mailbox<SubscriptionMessage>, source: EventEmitter | EventTarget, events: string | string[]): Operation; |
@@ -8,4 +8,3 @@ "use strict"; | ||
exports.any = pattern_2.any; | ||
const ensure_1 = require("./ensure"); | ||
const event_source_1 = require("./event-source"); | ||
const events_2 = require("@effection/events"); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -71,12 +70,11 @@ class Mailbox { | ||
return yield effection_1.spawn(function* () { | ||
for (let name of typeof events === 'string' ? [events] : events) { | ||
let listener = (...args) => { | ||
mailbox.send({ event: name, args }); | ||
}; | ||
event_source_1.addListener(source, name, listener); | ||
yield ensure_1.ensure(() => { | ||
event_source_1.removeListener(source, name, listener); | ||
for (let name of [].concat(events)) { | ||
yield effection_1.fork(function* () { | ||
let events = yield events_2.on(source, name); | ||
while (true) { | ||
let args = yield events.next(); | ||
mailbox.send({ event: name, args }); | ||
} | ||
}); | ||
} | ||
yield; | ||
}); | ||
@@ -83,0 +81,0 @@ } |
export declare function compile(pattern: unknown): (target: unknown) => boolean; | ||
export declare function any(type: unknown): (value: unknown) => boolean; | ||
export declare function any(type: unknown): ((value: unknown) => boolean) | (() => boolean); |
@@ -12,3 +12,3 @@ "use strict"; | ||
else if (typeof (pattern) === "object") { | ||
return typeof (target) === 'object' && pattern !== null && Object.entries(pattern).every(([key, value]) => compile(value)(target && target[key])); | ||
return typeof (target) === 'object' && Object.entries(pattern).every(([key, value]) => compile(value)(target[key])); | ||
} | ||
@@ -15,0 +15,0 @@ else if (typeof (pattern) === "function") { |
{ | ||
"name": "@bigtest/effection", | ||
"version": "0.1.1-b18ad89", | ||
"version": "0.1.1-bcea1fb", | ||
"description": "Collection of handly utilities for working with effection. May find a different home later", | ||
@@ -18,8 +18,8 @@ "main": "dist/index.js", | ||
"mocha": "mocha -r ts-node/register", | ||
"prepack": "tsc --outdir dist --declaration --sourcemap" | ||
"prepack": "tsc --outdir dist --declaration --sourcemap --module commonjs" | ||
}, | ||
"devDependencies": { | ||
"@frontside/tsconfig": "*", | ||
"@types/mocha": "^7.0.1", | ||
"@types/node": "^12.7.11", | ||
"effection": "^0.6.0", | ||
"expect": "^24.9.0", | ||
@@ -29,6 +29,9 @@ "mocha": "^6.2.2", | ||
}, | ||
"dependencies": { | ||
"@types/node": "^12.7.11", | ||
"peerDependencies": { | ||
"effection": "^0.6.0" | ||
}, | ||
"dependencies": { | ||
"@effection/events": "^0.6.1", | ||
"@types/node": "^12.7.11" | ||
}, | ||
"volta": { | ||
@@ -35,0 +38,0 @@ "node": "12.16.0", |
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
11855
3
15
165
+ Added@effection/events@^0.6.1
+ Added@effection/events@0.6.1(transitive)
- Removedeffection@^0.6.0