TLDR; I believe an example like this should be added to the README,
P().then(function (port) { throw 'boom!';}).catch(console.error)
Hi,
I ve decided today to start learning promise, i was still stuck into streams ; 0
I would just like to share with you my little experiment to improve the README.
I wrote some shit like this
var Promise = require('promise');
module.exports = function (port, host) {
var p = ((port) && Promise.denodeify(function(then){then(null, port)}) ) || require('get-port');
return p().then(function (port){
if (!(port).match(/[^:]+:[^:]+/)) port = host + ':' + port;
return port;
})
}
Which bugs in if (!(port).match(/[^:]+:[^:]+/)) port = host + ':' + port; because port is an int, but match belong to String.
Anyway, the fact is the error was caught by the promise, and did not produce any output.
So i was kind of like wtf ?! for a while...
Maybe i misread the README and missed something, but i believe it worth to show somewhere something like
P().then(function (port) { throw 'boom!';}).catch(console.error)
just to let me people come in and fail in a friendly way while learning and developing.
TLDR; I believe an example like this should be added to the README,
Hi,
I ve decided today to start learning promise, i was still stuck into streams ; 0
I would just like to share with you my little experiment to improve the README.
I wrote some shit like this
Which bugs in
if (!(port).match(/[^:]+:[^:]+/)) port = host + ':' + port;becauseportis anint, butmatchbelong toString.Anyway, the fact is the error was caught by the promise, and did not produce any output.
So i was kind of like
wtf ?!for a while...Maybe i misread the
READMEand missed something, but i believe it worth to show somewhere something likejust to let me people come in and fail in a friendly way while learning and developing.