@fioprotocol/fiojs
Version:
FioJS is a Utility SDK for packing, signing and encryption functionality for the FIO blockchain. It is used by the FIO TypeScript SDK
24 lines (20 loc) • 493 B
JavaScript
/**
Convert a synchronous function into a asynchronous one (via setTimeout)
wrapping it in a promise. This does not expect the function to have a
callback paramter.
@arg {function} func - non-callback function
@example promiseAsync(myfunction)
*/
module.exports = func => (
(...args) => (
new Promise((resolve, reject) => {
setTimeout(() => {
try {
resolve(func(...args))
} catch(err) {
reject(err)
}
})
})
)
)