RSS

Tag Archives: promise

Promises rejection (..but with style)

I find handy define this kind of function in my code:

function if_error(reject, err) {
  if (err) {
    console.error(err);
    reject(err);
  }
}

Now when I’ll need to handle a rejection, my code will be

something.can('go-wrong', (err) => {
  if_error(reject, err);
  ...

It’s something between pure functional programming and very readable code.

Advertisements
 
Leave a comment

Posted by on 2017/05/16 in dev

 

Tags: ,

I promise you a working jsdom

Working with jsdom is incredible, but most of the times you feel drowning in the callback hell
.
Here’s a template (soon on my github) that makes everything oven-ready 😉

UPDATE: added V2 that handles the NEW jsdom (see below)

And, as always, under 100 lines of code! =)

 
Leave a comment

Posted by on 2015/10/15 in dev

 

Tags: , , ,