import { isBindable } from '../shared/bindable' ; import { Agent } from './agent' ; export function singleton ( ) { return function < T extends { new ( ... args ) : Agent ; } > ( _Class ) : { new ( ... args ) : Agent ; } & T { let agent = new _Class ( ) ; if ( isBindable ( agent ) ) { agent . bind ( ) ; } return class extends _Class { static readonly instance = agent ; } ; } ; } export default singleton ;