Added basic TypeScript typings#23
Conversation
|
Could you also update |
|
This is so helpful, thanks for doing this! |
|
|
||
| declare interface ICodecParserOptions | ||
| { | ||
| onCodec?: () => any; |
There was a problem hiding this comment.
I think this can be narrowed to (string: codec) => {}. @eshaz onCodec is called with a string that is the name of the codec being used, and is expected to be an arbitrary action?
There was a problem hiding this comment.
I think it a union could be used here that is dependent on the passed in mimetype on instantiation.
- When the
mimetypeis likeaacormpeg, thenonCodecwill be called withaacandmpegrespectively. - When the
mimetypeis likeogg, thenonCodecmay be called with one offlac,opus, orvorbisdepending on the detected codec.
See: https://github.com/eshaz/codec-parser/search?q=onCodec and https://github.com/eshaz/codec-parser#properties
This is something I can add myself later too.
There was a problem hiding this comment.
For now I added an enum to constrain codec to the possible codec strings.
| @@ -0,0 +1,165 @@ | |||
| declare module "codec-parser" | |||
| { | |||
| declare type OggMimeType = "application/ogg" | "audio/ogg"; | |||
There was a problem hiding this comment.
Could these also be broken out into individual type aliases for each string?
|
Thanks @JohnWeisz for your contribution! I've been meaning to add types but you beat me to it :) Feel free to make updates based on the comments here if you want. Otherwise, I'll merge this into a branch and take care of the modifications. |
|
Thanks, I pushed a few more changes, in particular to get formatting done and flesh out the onCodec callbacks. Also I realized that, because of the Note: I ran prettier locally and it essentially affected every |
This PR adds
index.d.tscontaining typings, but without descriptions (as of now). This allowscodec-parserto be used in TypeScript projects nicely.There are no changes to runtime code, these are merely declarations for IntelliSense, etc. to work better.