{"id":21586583,"url":"https://github.com/woubuc/deferred","last_synced_at":"2026-05-17T12:14:26.502Z","repository":{"id":57169537,"uuid":"293750708","full_name":"woubuc/deferred","owner":"woubuc","description":"A Promise that can be resolved externally","archived":false,"fork":false,"pushed_at":"2021-10-11T13:16:44.000Z","size":92,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T23:40:59.755Z","etag":null,"topics":["async","deferred","javascript","promise","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@woubuc/deferred","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/woubuc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-08T08:37:14.000Z","updated_at":"2022-04-14T11:40:31.000Z","dependencies_parsed_at":"2022-09-13T22:52:26.453Z","dependency_job_id":null,"html_url":"https://github.com/woubuc/deferred","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woubuc%2Fdeferred","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woubuc%2Fdeferred/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woubuc%2Fdeferred/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woubuc%2Fdeferred/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/woubuc","download_url":"https://codeload.github.com/woubuc/deferred/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244189825,"owners_count":20412991,"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","deferred","javascript","promise","typescript"],"created_at":"2024-11-24T15:14:06.415Z","updated_at":"2026-05-17T12:14:21.470Z","avatar_url":"https://github.com/woubuc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deferred\nA Promise that can be resolved externally\n\n[![npm](https://img.shields.io/npm/v/@woubuc/deferred)](https://www.npmjs.com/package/@woubuc/deferred)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-green)](https://github.com/woubuc/deferred/blob/master/LICENSE.txt)\n[![install size](https://packagephobia.com/badge?p=@woubuc/deferred)](https://packagephobia.com/result?p=@woubuc/deferred)\n![Typescript type definitions included](https://img.shields.io/npm/types/@woubuc/deferred)\n\n## Installation\n```\nyarn add @woubuc/deferred\n```\n\nThe library is written in Typescript to types are included.\n\n## Usage\n```typescript\nimport Deferred from '@woubuc/deferred';\n\n// Use it as a regular promise\nlet promise = new Deferred((resolve, reject) =\u003e {\n    resolve('done');\n});\n\n// Or resolve it externally\npromise.resolve('done');\n\n// Or omit the promise body altogether\nlet deferred = new Deferred();\ndeferred.resolve('done');\n```\n\n#### API\n```typescript\nlet deferred = new Deferred\u003cT\u003e(promiseCallback);\n```\nCreates a new Deferred promise. Takes a `(resolve, reject)` callback just like a regular promise.\n\n- `\u003cT\u003e`: Type of the promise resolve value\n\n```typescript\ndeferred.resolve(value : T);\n```\nResolves the promise with `value`\n\n```typescript\ndeferred.reject(error ?: any);\n```\nRejects the promise with an optional `error`.\n\n#### Notes\n- Extends the native `Promise` object, so it should be fully compatible with regular promises\n- Resolving and rejecting follows the same rules as with regular promises (i.e. a promise can only be settled once)\n- Resolving the promise externally will not stop or code inside the constructor callback from executing\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwoubuc%2Fdeferred","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwoubuc%2Fdeferred","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwoubuc%2Fdeferred/lists"}