Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/poorlydefinedbehaviour/future
Promises implementation
https://github.com/poorlydefinedbehaviour/future
Last synced: 14 days ago
JSON representation
Promises implementation
- Host: GitHub
- URL: https://github.com/poorlydefinedbehaviour/future
- Owner: PoorlyDefinedBehaviour
- Created: 2019-12-13T20:21:29.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-05T18:44:42.000Z (almost 4 years ago)
- Last Synced: 2023-03-02T22:17:27.401Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 7.81 KB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Something that looks like a JavaScript Promise
```ts
import axios from "axios";
import Future from "./future/Future";function main(): void {
new Future((resolve, reject) => {
axios
.get(`https://api.github.com/users/poorlydefinedbehaviour/repos`)
.then(response => resolve(response))
.catch(error => reject(error));
})
.then(response => response.data)
.then(data => data[0].id)
.then(id => console.log(`id => ${id}`))
.catch(error => console.log("error", error));
}
main();
```