import { IPartitionLambda , LambdaCloseType } from "./lambdas" ; import { IQueuedMessage } from "./queue" ; /**
 * A lambda that passes the same message to one or more lambdas
 */ export class CombinedLambda implements IPartitionLambda { constructor ( protected readonly lambdas ) { } /**
     * Processes an incoming message
     */ public handler ( message ) { const promises = [ ] ; for ( const lambda of this . lambdas ) { const optionalPromise = lambda . handler ( message ) ; if ( optionalPromise !== undefined ) { promises . push ( optionalPromise ) ; } } return promises . length > 0 ? Promise . all ( promises ) as any : undefined ; } /**
     * Closes the lambda. After being called handler will no longer be invoked and the lambda is expected to cancel
     * any deferred work.
     */ public close ( closeType ) { for ( const lambda of this . lambdas ) { lambda . close ( closeType ) ; } } }