a small node project for exploring Promise functionality added with ES6
- pinky swear
- install dependencies with yarn or npm install
yarn
or
npm install
- run npm start to start the program
npm start
- Start making and breaking those Promises by uncommenting out the blocks of code you'd like to run.
The async operations are created throughout the workshop by using the following promisified functions:
Promisified fs.readFile
return new Promise(function (resolve, reject) {
fs.readFile(filePath, function (err, file) {
if (err) {
console.error('There\'s been a grevious error')
return reject(new Error('there\'s no file there'))
}
resolve(file)
})
})
}
and Promisified bufferToString
return new Promise(function (resolve, reject) {
if (!buffer.length) {
console.error('Doesn\'t look like much of anything to me...')
return reject(new Error('buffer empty!'))
}
resolve(buffer.toString('utf8'))
})
}
Pinky Promise was inspired by We Have A Problem with Promises by Nolan Lawson
This project was made possible with:
-
and viewers like you, thank you!