Closed stevenwaterman closed 2 years ago
Now why didn't github notify me of new issues :thinking:
You're right, returning null is quite inelegant. I live too much in C land where returning null is a sensible way to handle an error :). Throwing an exception is the right solution, and I'll swap it around Soon™.
Fixed in af760c3
In the event that the requested configuration is unsupported when calling
getAudioDecoder
, it returns null. The return type isPromise<{...}>
so it looks like you can spread it, but doing so will cause a runtime error if it returns null.Relevant line: https://github.com/ennuicastr/libavjs-webcodecs-polyfill/blob/401a3876600a891907816321f3f67496c84eca56/src/main.ts#L107
It'd be better to throw an error or reject the promise. At the very least the return type should be updated to use a union type with null, so that it's a compiler error if you try and spread it / don't check for null.
This applies to to both the video/audio methods and the encoder/decoder methods, ie all 4 of them