https://github.com/fabiosantoscode/user-async-function
Take async functions from user code, whether they're promise-returning functions, callback-calling functions, or async/await functions
https://github.com/fabiosantoscode/user-async-function
Last synced: about 1 year ago
JSON representation
Take async functions from user code, whether they're promise-returning functions, callback-calling functions, or async/await functions
- Host: GitHub
- URL: https://github.com/fabiosantoscode/user-async-function
- Owner: fabiosantoscode
- Created: 2018-07-16T16:42:39.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T03:19:53.000Z (over 3 years ago)
- Last Synced: 2025-02-26T09:15:57.470Z (about 1 year ago)
- Language: JavaScript
- Size: 220 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# user-async-function
[](https://travis-ci.org/fabiosantoscode/user-async-function) [](https://coveralls.io/github/fabiosantoscode/user-async-function?branch=master)
This module exports a function that calls a user function and waits for its completion. This function can be a callback-calling function, an async/await function, or a promise-returning function.
## How to use
```javascript
const userAsyncFunction = require('user-async-function')
// somewhere in your code...
function someFunction(userOptions) {
userAsyncFunction(userOptions.someAsyncFunction).then(...)
}
// or in an async function
async function someFunction(userOptions) {
await userAsyncFunction(userOptions.someAsyncFunction)
}
// Pass extra arguments at will
// They will be passed to the user function (before the callback)
userAsyncFunction(fn, 'arg1', 'arg2'/*, ...*/)
```