I was discussing with Chris Mills how to build an example for Web APIs that was clear enough yet showed some sort of API usage in action. He had chosen the Battery API which is, effectively, simple enough. But I had a question: what does this API report when you run it in a device without battery?
Nothing better than building an example, so that's what I did.
On a laptop
It reports the battery level and discharging / charging, plus the time left, if not at the maximum level already.
On a desktop
It reports battery level at 100%, charging, and 0 seconds to charge.
A final note/remark: while going through the API docs I found it so very synchronous and unpromise-y! If this API was written nowadays it would probably be done with Promises or some sort of asynchronicity by default. I wonder if that will be retrofitted.