mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 19:03:46 +02:00
Add some more argument validation
This commit is contained in:
@@ -24,6 +24,16 @@ export class Input {
|
||||
_format: InputFormat | null = null;
|
||||
|
||||
constructor(options: InputOptions) {
|
||||
if (!options || typeof options !== 'object') {
|
||||
throw new TypeError('options must be an object.');
|
||||
}
|
||||
if (!Array.isArray(options.formats) || options.formats.some(x => !(x instanceof InputFormat))) {
|
||||
throw new TypeError('options.formats must be an array of InputFormat.');
|
||||
}
|
||||
if (!(options.source instanceof Source)) {
|
||||
throw new TypeError('options.source must be a Source.');
|
||||
}
|
||||
|
||||
this._formats = options.formats;
|
||||
this._source = options.source;
|
||||
this._mainReader = new Reader(options.source);
|
||||
|
||||
Reference in New Issue
Block a user