forked from video-dev/hls.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix/ll-hls-endofstream: Add check for at least one part for endofs…
…tream partList check. Add tests. Create simple mock for TimeRanges for tests.
- Loading branch information
1 parent
604bdac
commit 1de06e9
Showing
3 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const assertValidRange = (name, length, index) => { | ||
if (index >= length || index < 0) { | ||
throw new DOMException( | ||
`Failed to execute '${name}' on 'TimeRanges': The index provided (${index}) is greater than the maximum bound (${length}).` | ||
); | ||
} | ||
return true; | ||
}; | ||
|
||
export class TimeRangesMock { | ||
_ranges = []; | ||
|
||
// Accepts an argument list of [start, end] tuples or { start: number, end: number } objects | ||
constructor(...ranges) { | ||
this._ranges = ranges.map((range) => | ||
Array.isArray(range) ? range : [range.start, range.end] | ||
); | ||
} | ||
|
||
get length() { | ||
const { _ranges: ranges } = this; | ||
return ranges.length; | ||
} | ||
|
||
start(i) { | ||
const { _ranges: ranges, length } = this; | ||
assertValidRange('start', length, i); | ||
return ranges[i] && ranges[i][0]; | ||
} | ||
|
||
end(i) { | ||
const { _ranges: ranges, length } = this; | ||
assertValidRange('end', length, i); | ||
return ranges[i] && ranges[i][1]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters