not solution but maybe workaround or thing to check - you can retype the array as Uint8Array in place (they share same memory) and see how that one gets written or check how it compares to 'bad' file you have.
>var d8 = new Uint8Array(d.buffer)
or even check d.buffer - that will be probably the same byte array as d8 would be
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
not solution but maybe workaround or thing to check - you can retype the array as Uint8Array in place (they share same memory) and see how that one gets written or check how it compares to 'bad' file you have.
or even check
d.buffer
- that will be probably the same byte array as d8 would be