This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // script to test build of a create react app project with an /app_path prefix | |
| // and an api backend served on /api, run it with node | |
| const express = require('express'); | |
| const path = require('path'); | |
| const app = express(); | |
| const proxy = require('http-proxy-middleware'); | |
| app.use('/app_path', express.static(path.join(__dirname, 'build'), {})); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const firstThatCompleteSuccessfullyES6 = (options) => { | |
| // return the first promise that resolve | |
| const oneSuccess = (promises) => Promise.all(promises.map(p => { | |
| // If a request fails, count that as a resolution so it will keep | |
| // waiting for other possible successes. If a request succeeds, | |
| // treat it as a rejection so Promise.all immediately bails out. | |
| return p.then( | |
| (val) => { return Promise.reject(val); }, | |
| (err) => { return Promise.resolve(err); } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function firstThatCompleteSuccessfully(options) { | |
| // return the first promise that resolve | |
| function oneSuccess(promises){ | |
| return Promise.all(promises.map( | |
| function(p) { | |
| // If a request fails, count that as a resolution so it will keep | |
| // waiting for other possible successes. If a request succeeds, | |
| // treat it as a rejection so Promise.all immediately bails out. | |
| return p.then( |