{"id":15646753,"url":"https://github.com/jonaskuske/promise-aplus","last_synced_at":"2025-07-14T10:07:55.536Z","repository":{"id":63737918,"uuid":"569922603","full_name":"jonaskuske/promise-aplus","owner":"jonaskuske","description":"🔮 An A+ compliant Promise implementation","archived":false,"fork":false,"pushed_at":"2022-11-25T02:14:08.000Z","size":1183,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T23:17:53.759Z","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/jonaskuske.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}},"created_at":"2022-11-23T23:38:09.000Z","updated_at":"2024-05-11T09:29:18.000Z","dependencies_parsed_at":"2023-01-22T06:16:14.916Z","dependency_job_id":null,"html_url":"https://github.com/jonaskuske/promise-aplus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jonaskuske/promise-aplus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonaskuske%2Fpromise-aplus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonaskuske%2Fpromise-aplus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonaskuske%2Fpromise-aplus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonaskuske%2Fpromise-aplus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonaskuske","download_url":"https://codeload.github.com/jonaskuske/promise-aplus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonaskuske%2Fpromise-aplus/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265277588,"owners_count":23739417,"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-03T12:14:36.899Z","updated_at":"2025-07-14T10:07:55.401Z","avatar_url":"https://github.com/jonaskuske.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A+ compliant promise implementation\n\n\u003ca href=\"https://promisesaplus.com/\"\u003e\n    \u003cimg src=\"https://promisesaplus.com/assets/logo-small.png\" alt=\"Promises/A+ logo\"\n         title=\"Promises/A+ 1.1 compliant\" align=\"right\" /\u003e\n\u003c/a\u003e\n\nA Promise implementation that utilizes modern ES2022 features like private class fields and fully complies with the [Promises/A+ 1.1.0 specification](https://promisesaplus.com/). Requires a runtime with `queueMicrotask` like browsers or Node.\n\n### Available functions\n\n```js\n// Create new Promise that immediately resolves\npromise = Promise.resolve(valueOrThenable)\n\n// Create new Promise that immediately rejects\npromise = Promise.reject(reason)\n\n// Create new Promise, must pass executor functiom\npromise = new Promise((resolve, reject) =\u003e {})\n\n// Return new Promises with resolve/reject handlers applied\npromise.then(onResolve, onReject)\npromise.catch(onReject)\n```\n\n### Example\n\n```js\nimport { Promise } from \"./promise.js\"\n\nfunction retryIfEmpty(fn, retry = 1, signal) {\n\tretry = Math.max(0, retry)\n\n\tconst end = new (class extends Error {\n\t\tname = \"RetryError\"\n\t\tmessage = \"maximum tries reached\"\n\t})()\n\n\treturn new Promise((resolve, reject) =\u003e {\n\t\tsignal?.throwIfAborted()\n\t\tsignal?.addEventListener(\"abort\", reject)\n\n\t\tPromise.resolve(fn()).then((val) =\u003e {\n\t\t\tresolve(\n\t\t\t\tval ?? (retry \u003e 0 ? retryIfEmpty(fn, --retry, signal) : Promise.reject(end)),\n\t\t\t)\n\t\t}, reject)\n\t})\n}\n\nretryIfEmpty(() =\u003e Math.random() \u003e 0.5 || null, 2).catch((e) =\u003e {\n\tif (e.name !== \"RetryError\") throw e\n\treturn false\n})\n```\n\n### Verify\n\n**`yarn test`**: Run A+ test suite against this Promise implementation\n\n**`yarn test-builtin`**: Run A+ test suite against the native built-in `Promise`\n\n**`yarn test-deferred`**: Run deferred tests and A+ test suite against `DeferredPromise`\n\n\u003cbr\u003e\n\n---\n\n\u003cbr\u003e\n\n©️ 2022, Jonas Kuske\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonaskuske%2Fpromise-aplus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonaskuske%2Fpromise-aplus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonaskuske%2Fpromise-aplus/lists"}