import nuid = require ( 'nuid' ) ; /**
 * Create a properly formatted inbox subject.
 */ export function createInbox ( ) { return `_INBOX.${ nuid . next ( ) }` ; } hidden export function extend ( a , ... b ) { for ( let i = 0 ; i < b . length ; i ++ ) { let o = b [ i ] ; Object . keys ( o ) . forEach ( function ( k ) { a [ k ] = o [ k ] ; } ) ; } return a ; } export function delay ( millis ) { return new Promise < any > ( ( resolve ) => { setTimeout ( resolve , millis ) ; } ) ; } hidden export function shuffle ( a ) { for ( let i = a . length - 1 ; i > 0 ; i -- ) { const j = Math . floor ( Math . random ( ) * ( i + 1 ) ) ; [ a [ i ] , a [ j ] ] = [ a [ j ] , a [ i ] ] ; } return a ; } export function settle ( a ) { if ( Array . isArray ( a ) ) { return Promise . resolve ( a ) . then ( _settle ) ; } else { return Promise . reject ( new TypeError ( 'argument requires an array of promises' ) ) ; } } function _settle ( a ) { return Promise . all ( a . map ( ( p ) => { return Promise . resolve ( p ) . then ( _resolve , _resolve ) ; } ) ) ; } function _resolve ( r ) { return r ; }