Sure
Implementing Thenable.
Install
npm install @michgonch/sure
Usage
const Sure = require("./sure");
new Sure(resolve => {
setTimeout(() => {
resolve(`Hello, Promise!`);
}, 1000);
}).then(msg => console.log(msg));
(async () => {
const msg = await new Sure(resolve => {
setTimeout(() => {
resolve(`Hello, Async!`);
}, 2000);
});
console.log(msg);
})();
Inspiration
How to make a beautiful, tiny npm package and publish it
Write Your Own Node.js Promise Library from Scratch
License
MIT.