Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

1234567891011121314151617181920212223242526272829
  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. }