Failure to read header results in writing to stderr
https://github.com/rii-mango/NIFTI-Reader-JS/blob/0e406b03775d5687911f9440dffa65d7b0886137/src/nifti.ts#L143-L145
It's not ideal to have console.error obligatorily called by a library, as it pollutes my output. I'm going to handle a null return value myself. Would it be possible to either remove the call or make it possible to turn off?
In the short term, I'm just wrapping:
function readHeaderQuiet(buf: ArrayBuffer) {
const console_error = console.error
console.error = () => {}
const header = readHeader(buf)
console.error = console_error
return header
}
@effigies, would you prefer throw new Error('That file does not appear to be NIFTI!')? I think it is definitely helpful to tell the user something doesn't look correct. I have personally found this useful in Niivue.
I'm perfectly happy with null, but I can catch an error, too.
Closing as the PR from @nellh has been merged into the release version.