bd48c5f0a4739cf774a2e6513b39d859b8dc5289e1176867c7a5b391a5c41062fc8bd75c5504b96bef88118e66c834e9d9283b98e65119701859eca41202d5 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # async-function <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
  2. [![github actions][actions-image]][actions-url]
  3. [![coverage][codecov-image]][codecov-url]
  4. [![License][license-image]][license-url]
  5. [![Downloads][downloads-image]][downloads-url]
  6. [![npm badge][npm-badge-png]][package-url]
  7. A function that returns the normally hidden `AsyncFunction` constructor, when available.
  8. ## Getting started
  9. ```sh
  10. npm install --save async-function
  11. ```
  12. ## Usage/Examples
  13. ```js
  14. const assert = require('assert');
  15. const AsyncFunction = require('async-function')();
  16. const fn = new AsyncFunction('return 1');
  17. assert.equal(fn.toString(), 'async function anonymous(\n) {\nreturn 1\n}');
  18. fn().then(x => {
  19. assert.equal(x, 1);
  20. });
  21. ```
  22. ## Tests
  23. Clone the repo, `npm install`, and run `npm test`
  24. [package-url]: https://npmjs.org/package/async-function
  25. [npm-version-svg]: https://versionbadg.es/ljharb/async-function.svg
  26. [deps-svg]: https://david-dm.org/ljharb/async-function.svg
  27. [deps-url]: https://david-dm.org/ljharb/async-function
  28. [dev-deps-svg]: https://david-dm.org/ljharb/async-function/dev-status.svg
  29. [dev-deps-url]: https://david-dm.org/ljharb/async-function#info=devDependencies
  30. [npm-badge-png]: https://nodei.co/npm/async-function.png?downloads=true&stars=true
  31. [license-image]: https://img.shields.io/npm/l/async-function.svg
  32. [license-url]: LICENSE
  33. [downloads-image]: https://img.shields.io/npm/dm/async-function.svg
  34. [downloads-url]: https://npm-stat.com/charts.html?package=async-function
  35. [codecov-image]: https://codecov.io/gh/ljharb/async-function/branch/main/graphs/badge.svg
  36. [codecov-url]: https://app.codecov.io/gh/ljharb/async-function/
  37. [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/async-function
  38. [actions-url]: https://github.com/ljharb/async-function/actions