export interface IMessagePackage { sequence ? : string ; message ? : any ; created ? : number ; } export const getSequence = ( function ( ) { let sequence = Date . now ( ) ; return function ( ) { return `${ process . pid }:${ sequence ++ }` ; } ; } ( ) ) ; export class IPCMessagePackage { public sequence : string = '' ; public message : any ; public created : number ; constructor ( params ) { if ( typeof params !== 'object' || params === null || params . message === undefined ) { throw new Error ( `At least property "message" should be defined` ) ; } if ( typeof params . sequence !== 'string' || params . sequence . trim ( ) === '' ) { params . sequence = getSequence ( ) ; } if ( params . created === undefined ) { params . created = Date . now ( ) ; } this . sequence = params . sequence ; this . message = params . message ; this . created = params . created ; } }