{"id":20366583,"url":"https://github.com/hookyns/promisesource","last_synced_at":"2026-05-07T23:04:41.058Z","repository":{"id":57331287,"uuid":"271626803","full_name":"Hookyns/PromiseSource","owner":"Hookyns","description":"Promise manageable from outer scope, similar to C#'s TaskCompletionSource","archived":false,"fork":false,"pushed_at":"2020-08-09T13:54:40.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-28T05:29:01.265Z","etag":null,"topics":["completion","javascript","nodejs","promise","source","taskcompletionsource","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/Hookyns.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":"2020-06-11T19:07:16.000Z","updated_at":"2021-04-12T11:04:06.000Z","dependencies_parsed_at":"2022-09-16T17:41:46.215Z","dependency_job_id":null,"html_url":"https://github.com/Hookyns/PromiseSource","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hookyns%2FPromiseSource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hookyns%2FPromiseSource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hookyns%2FPromiseSource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hookyns%2FPromiseSource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hookyns","download_url":"https://codeload.github.com/Hookyns/PromiseSource/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241908331,"owners_count":20040611,"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":["completion","javascript","nodejs","promise","source","taskcompletionsource","typescript"],"created_at":"2024-11-15T00:25:43.540Z","updated_at":"2026-05-07T23:04:40.970Z","avatar_url":"https://github.com/Hookyns.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# Promise Completion Source\nPromise manageable from outer scope, similar to C#'s TaskCompletionSource\n\n## Synopsis\n```typescript\nclass PromiseSource\u003cTResult\u003e {\n    get promise(): Promise\u003cTResult\u003e;\n    get resolved(): boolean;\n    get rejected(): boolean;\n    get completed(): boolean;\n    constructor(timeout?: number);\n    reject(reason?: any): void;\n    resolve(value?: TResult): void;\n}\n```\n\n## Example\n```typescript\nimport PromiseSource from \"promise-cs\";\n\nfunction doSomething(): Promise\u003cnumber\u003e\n{\n\tlet ps = new PromiseSource\u003cnumber\u003e(/* optional timeout in millisecond */);\n\n\t// Some async action, event or something\n\tsomeAsyncAction((err, result) =\u003e {\n\t\tif (err) {\n\t\t\tps.reject(err);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tps.resolve(result);\n\t});\n\n\treturn ps.promise;\n}\n\ndoSomething()\n\t.then(num =\u003e console.log(num))\n\t.catch(reason =\u003e console.error(reason))\n;\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhookyns%2Fpromisesource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhookyns%2Fpromisesource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhookyns%2Fpromisesource/lists"}