const createResource = ( promise ) => { let status = 'pending' ; let result ; let suspender = promise . then ( ( response ) => { status = 'success' ; result = response ; } , ( error ) => { status = 'error' ; result = error ; } ) ; return { read ( ) { switch ( status ) { case 'pending' : throw { suspender , status } ; case 'error' : throw result ; default : return result ; } } , } ; } ; export default createResource ;