async function downloadPromise( url, path, time ) {
	let writeStream;
	let incomingMessage;
	let timeout = null;

	try {
		writeStream = new WriteStream( path );
		incomingMessage = await getRedirected( url );

		await new Promise( ( resolve, reject ) => {
			writeStream.once( "error", reject );
			writeStream.once( "finish", resolve );

			incomingMessage.once( "error", reject );
			incomingMessage.once( "unpipe", () => reject( new Error( "I/O error" ) ) );

			// link readStream and writeStream
			incomingMessage.pipe( writeStream, { end: true } );

			if ( time ) {
				timeout = setTimeout( () => reject( new Error( "Timeout" ) ), time );
			}
		});
	} finally {
		if ( timeout ) {
			clearTimeout( timeout );
		}
		/* istanbul ignore else */
		if ( !incomingMessage.destroyed ) {
			incomingMessage.destroy();
		}
	}
}
@param {Url} url
@param {string} path
@param {number?} time
@returns {Promise}