From a068f1517651e7fc2008bbbceb6d02d14498a2a0 Mon Sep 17 00:00:00 2001 From: Miraclx Date: Wed, 8 Jul 2020 22:10:04 +0100 Subject: [PATCH] Document and type the newer fields in the HeaderSlice --- README.md | 2 ++ typings/index.d.ts | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a59c93..87a8b4c 100644 --- a/README.md +++ b/README.md @@ -301,7 +301,9 @@ xget(URL) ### HeadHandler: [`function`][function] - `props`: <[object][]> + - `chunks`: <[number][]> Number of chunks the resource can simultaneously provide. - `headers`: <[IncomingHttpHeaders][incominghttpheaders]> GET headers from the URL. + - `totalSize`: <[number][]> Actual size of the resource without an offset. - `acceptsRanges`: <[boolean][]> Whether or not the URL resource accepts byte ranges. - Returns: <[number] | void> An offset to begin streaming from. Analogous to the `.start` field in [XGETOptions](#xgetoptions). If void, defaults to `.start` or `0`; diff --git a/typings/index.d.ts b/typings/index.d.ts index d845718..6d99061 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -86,7 +86,14 @@ declare namespace xget { type MiddlewareStore = Map; - 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;