{"id":17609961,"url":"https://github.com/vixalien/async-wait-then","last_synced_at":"2025-03-29T23:45:31.371Z","repository":{"id":55916895,"uuid":"310951494","full_name":"vixalien/async-wait-then","owner":"vixalien","description":"wait, then do something asynchronously","archived":false,"fork":false,"pushed_at":"2024-09-24T11:09:54.000Z","size":102,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-05T01:41:59.727Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vixalien.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":null}},"created_at":"2020-11-07T23:36:29.000Z","updated_at":"2024-09-24T11:09:50.000Z","dependencies_parsed_at":"2024-10-23T00:39:44.334Z","dependency_job_id":null,"html_url":"https://github.com/vixalien/async-wait-then","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vixalien%2Fasync-wait-then","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vixalien%2Fasync-wait-then/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vixalien%2Fasync-wait-then/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vixalien%2Fasync-wait-then/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vixalien","download_url":"https://codeload.github.com/vixalien/async-wait-then/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246258862,"owners_count":20748573,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-22T17:24:18.082Z","updated_at":"2025-03-29T23:45:31.356Z","avatar_url":"https://github.com/vixalien.png","language":"JavaScript","funding_links":["https://www.paypal.com/donate/?cmd=_s-xclick\u0026hosted_button_id=DTV2TLWFUNHY8\u0026source=url"],"categories":[],"sub_categories":[],"readme":"async-wait-then\n----\n\na package to: **wait, then do something asynchronously**.\n\n- 📦 NPM: [npm][]\n- 🌎 Browser: [unpkg][]\n- 📂 Github: [vixalien/async-wait-then](https://www.github.com/vixalien/async-wait-then)\n- ✍ Author: [@vixalien](https://www.github.com/vixalien)\n\nwait is yet another step in making `setTimeout` more efficient.\n\nIt also allow easy use of the [promises][] while removing all the `async` and `await` and `Promise`s in your app.\n\n## installation\n\nTo use `wait`, you must first install it, it available on [npm][].\n\n### npm\n\n```bash\nnpm install async-wait-then\n```\n\nImport as npm module:\n\n```js\n// Using ES6 syntax\nimport wait from 'async-wait-then';\n\n// Using CommonJS or requireJS syntax\nlet wait = require('async-wait-then');\n```\n\n### browser\n\n```xml\n\u003cscript src=\"https://unpkg.com/async-wait-then\" type=\"script/javascript\" /\u003e\n```\n\n## example\n\nTo use it, you run `wait` with the time to wait as the only attribute\n\n```js\n// Pass on microseconds\nwait(100).then(() =\u003e console.log(\"Just waited 😎.\"));\n// Pass a string as parameter\nwait('1 minute').then(() =\u003e console.log(\"One minute done\"));\n```\n\n## api\n\n```js\nwait(time: (String|Number)): Promise\n```\n\n### Parameters:\n\n- **time**: Time to wait before resolving the promise. can be a string or a number. if it's a number it's parsed as micro-seconds. If a string, it's parsed according to the [ms][] utility.\n\n### Returns: \n\nA promise, which you can attach `then()` to. \n\n\u003e Note: wait only resolves, it _never_ rejects. In other words: it only allows `.then()` to be called, not `.catch()`, if you listen for `catch`, no error is likely to be thrown, so it's useless.\n\n## builds\n\nCommon builds are provided directly with the module, so if you ever wanted to require the umd build, you would do something like: `require(\"async-wait-then/dist/index.umd.js\")`, you can replace umd for:\n\n- esm\n- cjs (default)\n\nall builds are provided (for convenience) in `/dist` folder.\n\nalso, minified builds are available, just use `.min.js` as the extension\n\n## use cases\n\nYou may use this, when triggering notifications, or just to avoid using the ol' `setTimeout` API. In fact, it uses it, but with a Promise wrapper.\n\n## todo\n\n- Use `requestAnimationFrame` or `requestIdleCallback`, this is more efficient and works when no time was provided.\n- Add tests\n\n## thanks\n\nTo: @zeit (Vercel) for the [ms][], which is used to transform dirty strings into micro-seconds.\n\n## donate\n\n[donate][] on PayPal.\n\n[unpkg]: https://unpkg.com/async-wait-then\n[donate]: https://www.paypal.com/donate/?cmd=_s-xclick\u0026hosted_button_id=DTV2TLWFUNHY8\u0026source=url\n[ms]: https://github.com/zeit/ms\n[npm]: https://www.npmjs.com/package/async-wait-then\n[promises]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#Creating_a_Promise_around_an_old_callback_API\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvixalien%2Fasync-wait-then","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvixalien%2Fasync-wait-then","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvixalien%2Fasync-wait-then/lists"}