You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
497 B

  1. // API
  2. module.exports = abort;
  3. /**
  4. * Aborts leftover active jobs
  5. *
  6. * @param {object} state - current state object
  7. */
  8. function abort(state)
  9. {
  10. Object.keys(state.jobs).forEach(clean.bind(state));
  11. // reset leftover jobs
  12. state.jobs = {};
  13. }
  14. /**
  15. * Cleans up leftover job by invoking abort function for the provided job id
  16. *
  17. * @this state
  18. * @param {string|number} key - job id to abort
  19. */
  20. function clean(key)
  21. {
  22. if (typeof this.jobs[key] == 'function')
  23. {
  24. this.jobs[key]();
  25. }
  26. }