https://github.com/softonic/promisefallback
Receives an array of functions, values or promises and returns a promise that resolves with the first of them that resolves.
https://github.com/softonic/promisefallback
Last synced: about 1 year ago
JSON representation
Receives an array of functions, values or promises and returns a promise that resolves with the first of them that resolves.
- Host: GitHub
- URL: https://github.com/softonic/promisefallback
- Owner: softonic
- License: other
- Created: 2016-11-13T11:58:42.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-12-10T11:55:50.000Z (over 6 years ago)
- Last Synced: 2025-04-10T22:44:21.682Z (about 1 year ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 2
- Watchers: 21
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# promisefallback
Receives an array of functions, values or promises and returns a promise that resolves with the first of them that resolves.
## Installation
```bash
npm install promisefallback
```
## Usage
```javascript
import promiseFallback from 'promisefallback';
const promise = promiseFallback([
Promise.reject('foo'),
() => Promise.reject('bar'),
() => Promise.resolve('baz')
]);
promise.then(value => assert(value === 'baz'));
```
## Testing
Clone the repository and execute:
```bash
npm test
```
## Contribute
1. Fork it: `git clone https://github.com/softonic/promisefallback.git`
2. Create your feature branch: `git checkout -b feature/my-new-feature`
3. Commit your changes: `git commit -am 'Added some feature'`
4. Check the build: `npm run build`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D