espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.74k stars 741 forks source link

getPressure: add Promise<> and undefined to types #2422

Closed bobrippling closed 8 months ago

bobrippling commented 8 months ago

Some small typescript and doc tweaks to getPressure

gfwilliams commented 8 months ago

Thanks!

gfwilliams commented 8 months ago

I guess it raises the question of whether we should actually make getPressure always return a promise - but that doesn't help firmwares that are out there already

bobrippling commented 8 months ago

Yeah, although I suppose if we always return a promise, then for hardware without a barometer, we'd (probably) choose to resolve with undefined. So I think how things currently are is better, since then a caller will find out immediately whether they'll get a pressure reading, rather than when the promise resolves.

gfwilliams commented 8 months ago

Yes, I was thinking we might reject the promise - but as you say that would be harder to track down as it won't have a stack trace