import deprecated from 'deprecated-decorator' ; import { Resolvable , Promise } from '../promise' ; export type PromiseLockHandler < TResult > = ( ) => Resolvable < TResult > ; deprecated @ deprecated ( 'Lock' , '0.4' ) export class PromiseLock { private _promise = Promise . void ; lock < TResult > ( handler ) { let promise = this . _promise . then ( handler ) ; this . _promise = promise . void . fail ( reason => undefined ) ; return promise ; } get locker ( ) : < TResult > ( handler : PromiseLockHandler < TResult > ) => Promise < TResult > { return this . lock . bind ( this ) ; } }