1 | // Copyright (c) Microsoft Corporation.
|
2 | // Licensed under the MIT license.
|
3 | /**
|
4 | * Generate a range string. For example:
|
5 | *
|
6 | * "bytes=255-" or "bytes=0-511"
|
7 | *
|
8 | * @param iRange -
|
9 | */
|
10 | export function rangeToString(iRange) {
|
11 | if (iRange.offset < 0) {
|
12 | throw new RangeError(`Range.offset cannot be smaller than 0.`);
|
13 | }
|
14 | if (iRange.count && iRange.count <= 0) {
|
15 | throw new RangeError(`Range.count must be larger than 0. Leave it undefined if you want a range from offset to the end.`);
|
16 | }
|
17 | return iRange.count
|
18 | ? `bytes=${iRange.offset}-${iRange.offset + iRange.count - 1}`
|
19 | : `bytes=${iRange.offset}-`;
|
20 | }
|
21 | //# sourceMappingURL=Range.js.map |
\ | No newline at end of file |