Development Artifact Cleanup: ✅ BROTHER_NODE REORGANIZATION: Moved development test node to appropriate location - dev/test-nodes/brother_node/: Moved from root directory for better organization - Contains development configuration, test logs, and test chain data - No impact on production systems - purely development/testing artifact ✅ DEVELOPMENT ARTIFACTS IDENTIFIED: - Chain ID: aitbc-brother-chain (test/development chain) - Ports: 8010 (P2P) and 8011 (RPC) - different from production - Environment: .env file with test configuration - Logs: rpc.log and node.log from development testing session (March 15, 2026) ✅ ROOT DIRECTORY CLEANUP: Removed development clutter from production directory - brother_node/ moved to dev/test-nodes/brother_node/ - Root directory now contains only production-ready components - Development artifacts properly organized in dev/ subdirectory DIRECTORY STRUCTURE IMPROVEMENT: 📁 dev/test-nodes/: Development and testing node configurations 🏗️ Root Directory: Clean production structure with only essential components 🧪 Development Isolation: Test environments separated from production BENEFITS: ✅ Clean Production Directory: No development artifacts in root ✅ Better Organization: Development nodes grouped in dev/ subdirectory ✅ Clear Separation: Production vs development environments clearly distinguished ✅ Maintainability: Easier to identify and manage development components RESULT: Successfully moved brother_node development artifact to dev/test-nodes/ subdirectory, cleaning up the root directory while preserving development testing environment for future use.
106 lines
2.7 KiB
TypeScript
Executable File
106 lines
2.7 KiB
TypeScript
Executable File
/**
|
|
* Events allow for applications to use the observer pattern, which
|
|
* allows subscribing and publishing events, outside the normal
|
|
* execution paths.
|
|
*
|
|
* @_section api/utils/events:Events [about-events]
|
|
*/
|
|
import { defineProperties } from "./properties.js";
|
|
|
|
/**
|
|
* A callback function called when a an event is triggered.
|
|
*/
|
|
export type Listener = (...args: Array<any>) => void;
|
|
|
|
/**
|
|
* An **EventEmitterable** behaves similar to an EventEmitter
|
|
* except provides async access to its methods.
|
|
*
|
|
* An EventEmitter implements the observer pattern.
|
|
*/
|
|
export interface EventEmitterable<T> {
|
|
/**
|
|
* Registers a %%listener%% that is called whenever the
|
|
* %%event%% occurs until unregistered.
|
|
*/
|
|
on(event: T, listener: Listener): Promise<this>;
|
|
|
|
/**
|
|
* Registers a %%listener%% that is called the next time
|
|
* %%event%% occurs.
|
|
*/
|
|
once(event: T, listener: Listener): Promise<this>;
|
|
|
|
/**
|
|
* Triggers each listener for %%event%% with the %%args%%.
|
|
*/
|
|
emit(event: T, ...args: Array<any>): Promise<boolean>;
|
|
|
|
/**
|
|
* Resolves to the number of listeners for %%event%%.
|
|
*/
|
|
listenerCount(event?: T): Promise<number>;
|
|
|
|
/**
|
|
* Resolves to the listeners for %%event%%.
|
|
*/
|
|
listeners(event?: T): Promise<Array<Listener>>;
|
|
|
|
/**
|
|
* Unregister the %%listener%% for %%event%%. If %%listener%%
|
|
* is unspecified, all listeners are unregistered.
|
|
*/
|
|
off(event: T, listener?: Listener): Promise<this>;
|
|
|
|
/**
|
|
* Unregister all listeners for %%event%%.
|
|
*/
|
|
removeAllListeners(event?: T): Promise<this>;
|
|
|
|
/**
|
|
* Alias for [[on]].
|
|
*/
|
|
addListener(event: T, listener: Listener): Promise<this>;
|
|
|
|
/**
|
|
* Alias for [[off]].
|
|
*/
|
|
removeListener(event: T, listener: Listener): Promise<this>;
|
|
}
|
|
|
|
/**
|
|
* When an [[EventEmitterable]] triggers a [[Listener]], the
|
|
* callback always ahas one additional argument passed, which is
|
|
* an **EventPayload**.
|
|
*/
|
|
export class EventPayload<T> {
|
|
/**
|
|
* The event filter.
|
|
*/
|
|
readonly filter!: T;
|
|
|
|
/**
|
|
* The **EventEmitterable**.
|
|
*/
|
|
readonly emitter!: EventEmitterable<T>;
|
|
|
|
readonly #listener: null | Listener;
|
|
|
|
/**
|
|
* Create a new **EventPayload** for %%emitter%% with
|
|
* the %%listener%% and for %%filter%%.
|
|
*/
|
|
constructor(emitter: EventEmitterable<T>, listener: null | Listener, filter: T) {
|
|
this.#listener = listener;
|
|
defineProperties<EventPayload<any>>(this, { emitter, filter });
|
|
}
|
|
|
|
/**
|
|
* Unregister the triggered listener for future events.
|
|
*/
|
|
async removeListener(): Promise<void> {
|
|
if (this.#listener == null) { return; }
|
|
await this.emitter.off(this.filter, this.#listener);
|
|
}
|
|
}
|