import { injectable } from 'inversify' ; @ injectable ( ) export default class PromiseQueue { private queue : Promise < any > = Promise . resolve ( true ) ; param job return public add < T > ( job ) { return new Promise < T > ( ( resolve , reject ) => { this . queue = this . queue . then ( job ) . then ( ( result ) => { resolve ( result ) ; } ) . catch ( err => { reject ( err ) ; } ) ; } ) ; } }