Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

vivaxy/resolve-last

Repository files navigation

resolve-last

Build Status NPM Version NPM Downloads MIT License Standard Version Codecov

👌Only resolve last promise

Install

yarn add resolve-last
// or
npm install resolve-last

Usage

import resolveLast from 'resolve-last';

// yourAsyncFunction: (...args: Arguments) => Promise<Result>
const resolveLastAsyncFunction = resolveLast(yourAsyncFunction);

button.addEventListener('click', async function(e) {
  await resolveLastAsyncFunction(...args);
  // `console.log` only run with last called args
  console.log('resolved with ' + args.join(', '));
});

(Project created by create-n.)