victorb / trymodule

➰ It's never been easier to try nodejs modules!
1.14k stars 29 forks source link

support Promises #26

Closed philschatz closed 7 years ago

philschatz commented 7 years ago

Thanks for a great package to try out libraries (and the ipfs work)!

Several packages return Promise objects but when trying out libraries it would be nice to see what the Promise resolved to rather than just knowing that a Promise was returned. For example, if you run trymodule octokat and then enter (new octokat()).zen.read() in the REPL (which executes GET https://api.github.com/zen ) you get the following:

> (new octokat()).zen.read()
Promise { <pending> }
> 

With this code change you instead get the resolved Promise:

> (new octokat()).zen.read()
Returned a Promise. waiting for result...
'It\'s not fully shipped until it\'s fast.'
>

It seems libraries like es6-promise are still being actively downloaded (~250k/day) so I also included support for that

Btw, I stumbled upon this great package from http://www.thedotpost.com/2016/12/zeke-sikelianos-navigating-javascript-userland (thanks @zeke !)

zeke commented 7 years ago

Thanks for a great package to try out libraries

Hear hear.

zeke commented 7 years ago

Any way to add a test for this?

philschatz commented 7 years ago

Oops, I missed functional_test.sh . I added tests which verify a Promise was/wasn't detected and that the resolved/rejected value of the Promise was printed.

victorb commented 7 years ago

This. Change. Is. AWESOME! Thanks so much for this, such a useful feature but never crossed my mind! Thanks a lot for this and +++ for the added tests!

And thanks to both of you for the kind words and mentioning the module in various places, greatly appreciate it :)