1.0.2 • Published 4 years ago
@theenderofficial/custom-promise v1.0.2
custom-promise
Custom Promise Implementation
Installing
npm install @theenderofficial/custom-promise
Example
const customPromise = require('@theenderofficial/custom-promise')
// This outputs:
// SUCCESS
// Finally
const successPromise = new customPromise((rs, rj) => {
setTimeout(() => {
rs("Success");
}, 2000)
})
successPromise
.then(t => t.toUpperCase())
.then(t => console.log(t))
.catch(e => console.error("Error: ", e))
.finally(() => console.log("Finally"))
// This outputs:
// Error: Error
// Finally
const errorPromise = new customPromise((rs, rj) => {
setTimeout(() => {
rj("Error");
}, 2000)
})
errorPromise
.then(t => t.toUpperCase())
.then(t => console.log(t))
.catch(e => console.error("Error:", e))
.finally(() => console.log("Finally"))