{"id":18814556,"url":"https://github.com/raigorx/promises-js","last_synced_at":"2026-01-13T06:30:19.268Z","repository":{"id":243493971,"uuid":"812587671","full_name":"raigorx/Promises-JS","owner":"raigorx","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-10T00:47:23.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-30T00:49:07.520Z","etag":null,"topics":["async","await","educational","example","promises","setinterval","settimeout","tutorial"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raigorx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2024-06-09T10:24:21.000Z","updated_at":"2024-06-10T00:47:27.000Z","dependencies_parsed_at":"2024-06-09T11:36:46.357Z","dependency_job_id":"17e76ec8-eac7-4c21-a673-4ad71064eeb4","html_url":"https://github.com/raigorx/Promises-JS","commit_stats":null,"previous_names":["raigorx/promises-js"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raigorx%2FPromises-JS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raigorx%2FPromises-JS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raigorx%2FPromises-JS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raigorx%2FPromises-JS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raigorx","download_url":"https://codeload.github.com/raigorx/Promises-JS/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239750379,"owners_count":19690625,"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":["async","await","educational","example","promises","setinterval","settimeout","tutorial"],"created_at":"2024-11-07T23:41:52.643Z","updated_at":"2026-01-13T06:30:18.735Z","avatar_url":"https://github.com/raigorx.png","language":"JavaScript","readme":"# Overview\n\nThis script demonstrates how to work with promises and `setTimeout`/`setInterval` functions in JavaScript, utilizing an `AbortController` to manage and cancel asynchronous operations. It includes functions to create delays, cancel them, and sequence tasks while handling the complexities that arise from using raw `setTimeout` and `setInterval`.\n\n## Live demo\n\n[Live Demo](https://raigorx.github.io/Promises-JS/)\n\n### Task Functions\n\n- **zero()**: Demonstrates cancellation with a 0 delay.\n- **one()**: Shows the effect of catching errors from abort and continuing normal flow.\n- **two()**: Explains how `setTimeout` and `setInterval` behave when cancelled.\n- **three()**: Illustrates conditional execution based on `shouldSleep`.\n- **four()**: Demonstrates the race condition where sleeps never execute due to quick changes in `shouldSleep`.\n- **five()**: Shows how throwing an exception cancels function execution.\n- **six()**: Demonstrates handling promises and extracting resolved values using both `await` and `.then()` with `setTimeout`.\n- **seven()**: Demonstrates using `try/catch` with `await` and `.catch` with promises to handle errors.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraigorx%2Fpromises-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraigorx%2Fpromises-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraigorx%2Fpromises-js/lists"}