Skip to content

illuminatedspace/pinky-swear

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pinky Swear

a small node project for exploring Promise functionality added with ES6


Starting Up

  1. pinky swear

  1. install dependencies with yarn or npm install

yarn or npm install

  1. run npm start to start the program

npm start

  1. 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'))
})
}

Credits

Pinky Promise was inspired by We Have A Problem with Promises by Nolan Lawson

This project was made possible with:

  • nodemon

  • and viewers like you, thank you!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published