You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
681 B
39 lines
681 B
/**
|
|
* @typedef Slice
|
|
* @property {number} offset
|
|
* @property {number} length
|
|
*/
|
|
|
|
export class BaseSource {
|
|
/**
|
|
*
|
|
* @param {Slice[]} slices
|
|
* @returns {ArrayBuffer[]}
|
|
*/
|
|
async fetch(slices, signal = undefined) {
|
|
return Promise.all(
|
|
slices.map((slice) => this.fetchSlice(slice, signal)),
|
|
);
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param {Slice} slice
|
|
* @returns {ArrayBuffer}
|
|
*/
|
|
async fetchSlice(slice) {
|
|
throw new Error(`fetching of slice ${slice} not possible, not implemented`);
|
|
}
|
|
|
|
/**
|
|
* Returns the filesize if already determined and null otherwise
|
|
*/
|
|
get fileSize() {
|
|
return null;
|
|
}
|
|
|
|
async close() {
|
|
// no-op by default
|
|
}
|
|
}
|