https://github.com/beyondjs/pending-promise
https://github.com/beyondjs/pending-promise
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/beyondjs/pending-promise
- Owner: beyondjs
- License: mit
- Created: 2022-12-01T13:33:16.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-27T20:28:19.000Z (about 1 year ago)
- Last Synced: 2025-10-02T03:33:08.958Z (9 months ago)
- Language: TypeScript
- Size: 42 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @beyond-js/pending-promise
A `PendingPromise` class that extends the native `Promise` to provide externally accessible `resolve` and `reject`
methods.
## Installation
```sh
npm install @beyond-js/pending-promise
```
## Usage
```typescript
import { PendingPromise } from '@beyond-js/pending-promise/main';
const promise = new PendingPromise();
// Resolve the promise later
setTimeout(() => {
promise.resolve('Hello, world!');
}, 1000);
promise.then(value => {
console.log(value); // Output after 1 second: Hello, world!
});
```
## API
### `PendingPromise`
Extends the native `Promise` class with externally accessible `resolve` and `reject` methods.
#### Constructor
```typescript
new PendingPromise(executor?: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void)
```
- **executor**: Optional executor function that takes `resolve` and `reject` functions.