import { getOwner } from '../environment' ; import type { Fastboot } from './types' ; function hasFastBoot ( obj ) { return Object . prototype . hasOwnProperty . call ( obj , 'FastBoot' ) ; } function ownerHasLookup ( owner ) { return ! ! ( owner && 'lookup' in owner ) ; } export function getFastboot ( ctx ) { if ( typeof self != 'undefined' && hasFastBoot ( self ) && typeof self . FastBoot !== 'undefined' ) { const owner = getOwner ( ctx ) ; if ( ownerHasLookup ( owner ) && typeof owner . lookup === 'function' ) { return owner . lookup ( 'service:fastboot' ) as Fastboot ; } } return undefined ; } export function createPromise ( ) { let resolvePromise ; let rejectPromise ; const promise = new Promise < void > ( ( resolve , reject ) => { resolvePromise = resolve ; rejectPromise = reject ; } ) ; return [ promise , resolvePromise ! , rejectPromise ! ] ; } export function settled ( promise ? ) { return new Promise < void > ( ( resolve ) => { if ( promise ) { promise . then ( ( ) => resolve ( ) ) . catch ( ( ) => resolve ( ) ) ; } else { resolve ( ) ; } } ) ; }