Skip to content

Commit

Permalink
fix: inlets should have more control
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximvdw committed Nov 4, 2024
1 parent a42f2d0 commit 24c5439
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/graph/Edge.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PullOptions, PushOptions } from './options';
import { DataFrame } from '../data';
import { GraphNode } from './_internal/GraphNode';
import type { GraphNode } from './_internal/GraphNode';
import { PushCompletedEvent, PushError } from './events';
import { Inlet } from './Inlet';
import { Outlet } from './Outlet';
Expand Down Expand Up @@ -107,4 +107,12 @@ export class Edge<InOut extends DataFrame> extends EventEmitter implements Inlet
this.removeAllListeners(name);
return super.on(name, listener);
}

get inletNode(): GraphNode<any, InOut> {
return this.inputNode;
}

get outletNode(): GraphNode<InOut, any> {
return this.outputNode;
}
}
6 changes: 6 additions & 0 deletions src/graph/Inlet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DataFrame } from '../data';
import type { GraphNode } from './_internal/GraphNode';
import { PushCompletedEvent, PushError } from './events';
import { PullOptions, PushOptions } from './options';

Expand Down Expand Up @@ -37,4 +38,9 @@ export interface Inlet<In extends DataFrame> {
* @param {Function} listener Event callback
*/
on(name: 'push', listener: (frame: In, options?: PushOptions) => Promise<void> | void): this;

/**
* Get the node of the inlet
*/
get inletNode(): GraphNode<any, In>;
}
6 changes: 6 additions & 0 deletions src/graph/Outlet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DataFrame } from '../data';
import type { GraphNode } from './_internal/GraphNode';
import { PullOptions, PushOptions } from './options';

/**
Expand All @@ -20,4 +21,9 @@ export interface Outlet<Out extends DataFrame> {
* @param {Function} listener Event callback
*/
on(name: 'pull', listener: (options?: PullOptions) => Promise<void> | void): this;

/**
* Get the node of the outlet
*/
get outletNode(): GraphNode<Out, any>;
}
8 changes: 8 additions & 0 deletions src/graph/_internal/GraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ export abstract class GraphNode<In extends DataFrame, Out extends DataFrame>
this.on('completed', this._onCompleted.bind(this));
}

get inletNode(): GraphNode<any, Out> {
return this;
}

get outletNode(): GraphNode<In, any> {
return this;
}

logger(level: 'debug', message: string, data?: any): void;
logger(level: 'info', message: string, data?: any): void;
logger(level: 'warn', message: string, data?: any): void;
Expand Down

0 comments on commit 24c5439

Please sign in to comment.