lib/promise-lead-debounce/index.js
// allow only a single promise to be executed at once
allow only a single promise to be executed at once
allow only a single promise to be executed at once
function debounce (fn) {
  let promise = null
  return function (...args) {
    if (!promise) {
      promise = Promise.resolve(fn(...args))
        .finally(function () {
          promise = null
        })
    }
    return promise
  }
}
function debounce ( fn ) { let promise = null return function ( ... args ) { if ( ! promise ) { promise = Promise . resolve ( fn ( ... args ) ) . finally ( function ( ) { promise = null } ) } return promise } }
allow only a single promise to be executed at once
allow only a single promise to be executed at once