Collection of convenience code snippets (helpers) that aims to make it a little easier to work with vanilla JS
vanillajs-helpers > “promisefy”
► promisefy(fn: Function
): Function
Defined in promisefy.ts:22
Converts a callback based action into one returning a Promise instead.
function action(name, callback) { ... callback(); }
action = promisefy(action);
action
.then(() => 'all good')
.catch(() => 'Something went wrong');
Parameters:
Param | Type | Description |
---|---|---|
fn | Function |
- |
Returns: Function