mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-03 05:43:50 +02:00
Small adjustments to getSize change
This commit is contained in:
+6
-6
@@ -8,20 +8,20 @@ import { Source } from './source';
|
|||||||
* The options for creating an Input object.
|
* The options for creating an Input object.
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export type InputOptions = {
|
export type InputOptions<S extends Source = Source> = {
|
||||||
/** A list of supported formats. If the source file is not of one of these formats, then it cannot be read. */
|
/** A list of supported formats. If the source file is not of one of these formats, then it cannot be read. */
|
||||||
formats: InputFormat[];
|
formats: InputFormat[];
|
||||||
/** The source from which data will be read. */
|
/** The source from which data will be read. */
|
||||||
source: Source;
|
source: S;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an input media file. This is the root object from which all media read operations start.
|
* Represents an input media file. This is the root object from which all media read operations start.
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export class Input {
|
export class Input<S extends Source = Source> {
|
||||||
/** @internal */
|
/** @internal */
|
||||||
_source: Source;
|
_source: S;
|
||||||
/** @internal */
|
/** @internal */
|
||||||
_formats: InputFormat[];
|
_formats: InputFormat[];
|
||||||
/** @internal */
|
/** @internal */
|
||||||
@@ -31,7 +31,7 @@ export class Input {
|
|||||||
/** @internal */
|
/** @internal */
|
||||||
_format: InputFormat | null = null;
|
_format: InputFormat | null = null;
|
||||||
|
|
||||||
constructor(options: InputOptions) {
|
constructor(options: InputOptions<S>) {
|
||||||
if (!options || typeof options !== 'object') {
|
if (!options || typeof options !== 'object') {
|
||||||
throw new TypeError('options must be an object.');
|
throw new TypeError('options must be an object.');
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ export class Input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the source from which this input file reads its data. This is the same source that was passed to there
|
* Returns the source from which this input file reads its data. This is the same source that was passed to the
|
||||||
* constructor.
|
* constructor.
|
||||||
*/
|
*/
|
||||||
get source() {
|
get source() {
|
||||||
|
|||||||
+2
-2
@@ -14,8 +14,8 @@ export abstract class Source {
|
|||||||
_sizePromise: Promise<number> | null = null;
|
_sizePromise: Promise<number> | null = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns promise that resolves with the size of the file.
|
* Resolves with the total size of the file in bytes. This function is memoized, meaning only the first call
|
||||||
* If the size is not known, it will be retrieved from the source.
|
* will retrieve the size.
|
||||||
*/
|
*/
|
||||||
getSize() {
|
getSize() {
|
||||||
return this._sizePromise ??= this._retrieveSize();
|
return this._sizePromise ??= this._retrieveSize();
|
||||||
|
|||||||
Reference in New Issue
Block a user