vanillajs-helpers

Collection of convenience code snippets (helpers) that aims to make it a little easier to work with vanilla JS

View the Project on GitHub Tokimon/vanillajs-helpers

vanillajs-helpers > “promisefy”

External module: “promisefy”

Index

Functions


Functions

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