1.0.2 • Published 4 years ago

@theenderofficial/custom-promise v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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"))
1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago