Basic JS Promise Implementation for funzzies Open to suggestions for improvements.
$ npm install -S Promise
import Promise from 'Promise'
var Promise = require('Promise').default
.then chaining and async resolution/rejection.
returning of new promise chains in a .then, and forceful unwrapping to keep the chaining flat.
better rejection error handling
$ git clone <project>
$ npm install
$ npm run dev //edit src folder
$ npm run build
import Promise from 'Promise'
const p = new Promise((resolve, reject) => {
setTimeout(() => resolve(5), 1000)
})
.then((fulfilled) => {
console.log('fulfilled', fulfilled)
return "success"
}, (rejected) => {
console.log('rejected ', rejected)
})
.then((fulfilled) => {
console.log('fulfilled 2 ', fulfilled)
}, (rejected) => {
console.log('rejected 2 ', rejected)
})