import { compareObject , compareUnsortedPlainArrays } from "../helper" ; import Protocol , { ProtocolJSON , ProtocolLike } from "./Protocol" ; export interface NetworkLike { name : string ; protocol : Partial < ProtocolLike > ; nodes : any [ ] ; extra : { [ key ] : string ; } ; } export interface NetworkJSON { Name : string ; ProtocolConfiguration : ProtocolJSON ; Nodes : string [ ] ; ExtraConfiguration : { [ key ] : string ; } ; } param config export class Network { public name : string ; public protocol : Protocol ; public nodes : string [ ] ; public extra : { [ key ] : string ; } ; public constructor ( config = { } , name = null ) { this . name = config . Name || config . name || name || "RandomNet" ; const protocolLike = Object . assign ( { } , config . protocol || config . ProtocolConfiguration || { } ) ; this . protocol = new Protocol ( protocolLike ) ; this . nodes = config . Nodes || config . nodes || [ ] ; this . extra = Object . assign ( { } , config . ExtraConfiguration || config . extra || { } ) ; } /**
     * Exports the class as a JSON format.
     */ public export ( ) { return { ProtocolConfiguration : this . protocol . export ( ) , Name : this . name , ExtraConfiguration : this . extra , Nodes : this . nodes , } ; } public equals ( other ) { return ( this . name === other . name && this . protocol . equals ( other . protocol || { } ) && compareUnsortedPlainArrays ( this . nodes , other . nodes || [ ] ) && compareObject ( this . extra , other . extra || { } ) ) ; } } export default Network ;