2.0.2 • Published 5 years ago
promx v2.0.2
Installation
$ yarn add promx
If you prefer using npm:
$ npm i -S promx
Usage
promx will allow you to write code like this:
import promx from 'promx'
async function main() {
const [err, res] = await promx(fetch('http://example.com/movies.json'))
if (err) console.warn('failed to load data')
else console.log({ res })
}
main()
Instead of this:
async function main() {
try {
await fetch('http://example.com/movies.json')
} catch (err) {
console.warn('failed to load data')
return
}
console.log({ res })
}
main()
timeout the promise if it took longer then 1 second:
import promx from 'promx'
async function main() {
const [err, res] = await promx(fetch('http://example.com/movies.json'), { timeout: 1000 })
if (err) console.warn('failed to load data')
else console.log({ res })
}
main()
API
promx(promise, options)
promise
Type: Promise
Receives a promise that will eventually resolve or reject
options
Type: Object
options.timeout
Type: Number
timeout duration in ms before resolving with timout error
License
MIT © mouafa
2.0.2
5 years ago
2.0.1
5 years ago
2.0.0
5 years ago
2.0.0-beta.4
5 years ago
2.0.0-beta.3
5 years ago
2.0.0-beta.2
5 years ago
2.0.0-beta.1
5 years ago
2.0.0-beta.0
5 years ago
1.0.1
6 years ago
1.0.0
6 years ago
0.1.6
6 years ago
0.1.5
6 years ago
0.1.4
6 years ago
0.1.3
6 years ago
0.1.2
6 years ago
0.1.1
6 years ago
0.2.0-alpha.c3998fac
6 years ago
3.1.0-alpha.c3998fac
6 years ago