async.jsdoc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. Zombie Navigator API (ZAPI) documentation
  3. @copyright
  4. Copyright © 2016 Zombie Navigator Developers
  5. <br /><br />
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU Affero General Public License as
  8. published by the Free Software Foundation, either version 3 of the
  9. License, or (at your option) any later version.
  10. <br /><br />
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU Affero General Public License for more details.
  15. <br /><br />
  16. You should have received a copy of the GNU Affero General Public License
  17. along with this program. If not, see {@link http://www.gnu.org/licenses/}.
  18. <br /><br />
  19. The latest version of the GNU AGPL should be available here:
  20. {@link https://www.gnu.org/licenses/agpl.html}
  21. @file
  22. @module zombie/async
  23. @license AGPL-3.0+
  24. @version 0.6.0
  25. */
  26. /*
  27. This is not a script but a JSDoc documentation source.
  28. */
  29. /**
  30. Asynchronous sleep using Promise
  31. @example
  32. const {delay} = require('zombie/async');
  33. @param {number} s The number of seconds to sleep for
  34. @returns {Promise}
  35. @public
  36. */
  37. var delay = function () {};
  38. /**
  39. Run a generator as a coroutine using Promise
  40. @example
  41. const {run} = require('zombie/async');
  42. run(function* () {
  43. try {
  44. let result = yield new Promise(...);
  45. } catch (e) {
  46. // rejected
  47. }
  48. throw new Error();
  49. })
  50. .then(function (result) {
  51. // generator is finished
  52. })
  53. .catch(function (e) {
  54. // an error in generator
  55. });
  56. @param {function} genFunction Generator (coroutine) to run
  57. @returns {Promise}
  58. @public
  59. */
  60. var run = function () {};
  61. // vim: ts=4 noet ai ft=js