import { ProcessId , IProcess } from '@lib/process/process' ; /**
 * A pool of running processes.
 */ class ProcessPool { public readonly processes : { [ type in ProcessId ] : IProcess ; } = { } ; param process param id public add ( process , id ? ) { if ( ! id ) { id = process . getId ( ) ; if ( ! id ) { return ; } } this . processes [ id ! ] = process ; process . on ( 'close' , ( ) => { this . remove ( id ! ) ; } ) ; } param id public findProcess ( id ) { return this . processes [ id ] ; } /**
     * Remove a process from the pool by its id.
     */ public remove ( id ) { if ( typeof this . processes [ id ] !== 'undefined' ) { delete this . processes [ id ] ; } } /**
     * Clear the process pool.
     */ public clear ( ) { Object . keys ( this . processes ) . forEach ( id => { this . remove ( id ) ; } ) ; } } const pool = new ProcessPool ( ) ; export default pool ;