{"id":40149253,"url":"https://github.com/bramus/watchable-promise","last_synced_at":"2026-01-22T18:42:38.008Z","repository":{"id":332852928,"uuid":"1135241093","full_name":"bramus/watchable-promise","owner":"bramus","description":"A Promise whose state and value you can read","archived":false,"fork":false,"pushed_at":"2026-01-19T08:23:52.000Z","size":32,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-19T19:37:00.354Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bramus.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"bramus","-custom":["https://www.paypal.me/bramus","https://www.bram.us/"]}},"created_at":"2026-01-15T20:43:14.000Z","updated_at":"2026-01-19T08:23:12.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/bramus/watchable-promise","commit_stats":null,"previous_names":["bramus/watchable-promise"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/bramus/watchable-promise","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramus%2Fwatchable-promise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramus%2Fwatchable-promise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramus%2Fwatchable-promise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramus%2Fwatchable-promise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bramus","download_url":"https://codeload.github.com/bramus/watchable-promise/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramus%2Fwatchable-promise/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28606287,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T14:45:23.139Z","status":"ssl_error","status_checked_at":"2026-01-20T14:44:16.929Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-01-19T15:04:10.718Z","updated_at":"2026-01-21T17:02:04.335Z","avatar_url":"https://github.com/bramus.png","language":"TypeScript","funding_links":["https://github.com/sponsors/bramus","https://www.paypal.me/bramus","https://www.bram.us/"],"categories":[],"sub_categories":[],"readme":"# watchable-promise\n\nA Promise whose state and value you can read\n\n## Installation\n\n```bash\nnpm install watchable-promise\n```\n\n## Usage\n\n- Directly create a `WatchablePromise` instance:\n\n    ```javascript\n    import WatchablePromise from \"watchable-promise\";\n\n    const p = new WatchablePromise(resolve =\u003e setTimeout(() =\u003e resolve(\"foo\"), 100));\n\n    console.log(p.state); // pending\n    console.log(p.settled); // false\n    console.log(p.value); // undefined\n\n    const val = await p;\n\n    console.log(val) // \"foo\"\n    console.log(p.state); // fulfilled\n    console.log(p.settled); // true\n    console.log(p.value); // \"foo\"\n    ```\n\n- Using an existing `Promise` instance:\n\n    ```javascript\n    import WatchablePromise from 'watchable-promise';\n\n    const existingPromise = new Promise(resolve =\u003e setTimeout(() =\u003e resolve(\"foo\"), 100));\n    const p = WatchablePromise.from(existingPromise);\n\n    console.log(p.state); // pending\n    console.log(p.settled); // false\n    console.log(p.value); // undefined\n\n    const val = await p;\n\n    console.log(val) // \"foo\"\n    console.log(p.state); // fulfilled\n    console.log(p.settled); // true\n    console.log(p.value); // \"foo\"\n    ```\n\n- Using `WatchablePromise.withResolvers()`:\n\n    ```javascript\n    import WatchablePromise from 'watchable-promise';\n    \n    const { promise, resolve, reject } = WatchablePromise.withResolvers();\n\n    console.log(promise.state); // pending\n    console.log(promise.settled); // false\n    console.log(promise.value); // undefined\n    \n    await resolve(\"foo\");\n\n    console.log(promise.state); // fulfilled\n    console.log(promise.settled); // true\n    console.log(promise.value); // \"foo\"\n    ```\n\n- You can call `.resolve()` or `.reject()` on a `WatchablePromise` instance to resolve or reject it externally:\n\n    ```javascript\n    import WatchablePromise from \"watchable-promise\";\n\n    // Resolving\n    const p1 = new WatchablePromise(resolve =\u003e {});\n    p1.resolve(\"foo\");\n    const val = await p1;\n    console.log(val) // \"foo\"\n\n    // Rejecting\n    const p2 = new WatchablePromise((resolve, reject) =\u003e {});\n    p2.reject(\"bar\");\n    try {\n        await p2;\n    } catch (err) {\n        console.log(err) // \"bar\"\n    }\n    ```\n\n## License\n\n`watchable-promise` is released under the Apache 2.0 License. See the enclosed [`LICENSE`](./LICENSE) for details.\n\n## Disclaimer\n\nThis is not an officially supported Google product. I just happen to work there.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramus%2Fwatchable-promise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbramus%2Fwatchable-promise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramus%2Fwatchable-promise/lists"}