-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add missing src/receive-endpoint-self-connected-default.mjs from temp…
…late
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { ReceiveEndpointDefault } from "./receive-endpoint-default.mjs"; | ||
|
||
/** | ||
* Receiving endpoint wich can also send to itself | ||
*/ | ||
export class ReceiveEndpointSelfConnectedDefault extends ReceiveEndpointDefault { | ||
get isOut() { | ||
return true; | ||
} | ||
|
||
*connections() { | ||
yield this; | ||
yield* super.connections(); | ||
} | ||
|
||
addConnection(other, backpointer) { | ||
if (other === this) { | ||
return; | ||
} | ||
return super.addConnection(other, backpointer); | ||
} | ||
|
||
removeConnection(other, backpointer) { | ||
if (other === this) { | ||
return; | ||
} | ||
return super.removeConnection(other, backpointer); | ||
} | ||
|
||
isConnected(other) { | ||
if (this === other) { | ||
return true; | ||
} | ||
return super.isConnected(other); | ||
} | ||
|
||
async send(...args) { | ||
const interceptors = this.interceptors; | ||
let c = 0; | ||
|
||
const next = async (...args) => | ||
c >= interceptors.length | ||
? this.receive(...args) | ||
: interceptors[c++].receive(this, next, ...args); | ||
|
||
return next(...args); | ||
} | ||
} |