Skip to content

Commit

Permalink
Document and type the newer fields in the HeaderSlice
Browse files Browse the repository at this point in the history
  • Loading branch information
miraclx committed Jul 8, 2020
1 parent 50fccea commit a068f15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ xget(URL)
### <a id='headhandler'></a> HeadHandler: [`function`][function]

- `props`: &lt;[object][]&gt;
- `chunks`: &lt;[number][]&gt; Number of chunks the resource can simultaneously provide.
- `headers`: &lt;[IncomingHttpHeaders][incominghttpheaders]&gt; GET headers from the URL.
- `totalSize`: &lt;[number][]&gt; Actual size of the resource without an offset.
- `acceptsRanges`: &lt;[boolean][]&gt; Whether or not the URL resource accepts byte ranges.
- Returns: &lt;[number] | void&gt; An offset to begin streaming from. Analogous to the `.start` field in [XGETOptions](#xgetoptions). If void, defaults to `.start` or `0`;

Expand Down
9 changes: 8 additions & 1 deletion typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ declare namespace xget {

type MiddlewareStore = Map<string, any>;

type HeadHandler = (props: {headers: IncomingHttpHeaders, acceptsRanges: boolean}) => number | void;
interface HeaderSlice {
chunks: number;
headers: IncomingHttpHeaders;
totalSize: number;
acceptsRanges: boolean;
}

type HeadHandler = (props: HeaderSlice) => number | void;
type UseMiddlewareFn = (dataSlice: ChunkLoadInstance, store: MiddlewareStore) => NodeJS.ReadWriteStream;
type WithMiddlewareFn = (loadData: LoadDataSlice) => any;

Expand Down

0 comments on commit a068f15

Please sign in to comment.