@tokenizer/range
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -12,3 +12,3 @@ "use strict"; | ||
*/ | ||
async function tokenizer(rangeRequestClient, config) { | ||
function tokenizer(rangeRequestClient, config) { | ||
const factory = new range_request_factory_1.RangeRequestFactory(rangeRequestClient); | ||
@@ -15,0 +15,0 @@ return factory.initTokenizer(config); |
@@ -10,7 +10,22 @@ /// <reference types="node" /> | ||
export interface IContentRangeType { | ||
/** | ||
* Offset in fil, integer, indicating the first byte of the range | ||
*/ | ||
firstBytePosition?: number; | ||
/** | ||
* Offset in fil, integer, indicating the last byte of the range | ||
*/ | ||
lastBytePosition?: number; | ||
/** | ||
* Total file length | ||
*/ | ||
instanceLength?: number; | ||
} | ||
/** | ||
* Abstract interface to HTTP response information | ||
*/ | ||
export interface IHeadRequestInfo extends IFileInfo { | ||
/** | ||
* Range and file size specification | ||
*/ | ||
contentRange?: IContentRangeType; | ||
@@ -21,5 +36,18 @@ } | ||
} | ||
/** | ||
* Implementation of the range-request-client | ||
*/ | ||
export interface IRangeRequestClient { | ||
/** | ||
* Head request to determine the size and MIME-type of the file | ||
* @return HEAD-request information | ||
*/ | ||
getHeadInfo?(): Promise<IHeadRequestInfo>; | ||
/** | ||
* | ||
* @param method - HTTP method | ||
* @param range - Array of 2 numbers: The range-start and range-end. An integer indicating the beginning and the end of range request in bytes. | ||
* @return Range request response | ||
*/ | ||
getResponse(method: string, range?: [number, number]): Promise<IRangeRequestResponse>; | ||
} |
{ | ||
"name": "@tokenizer/range", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Range-request tokenizer adapter", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -13,2 +13,6 @@ [![Build Status](https://travis-ci.org/Borewit/tokenizer-range.svg?branch=master)](https://travis-ci.org/Borewit/tokenizer-range) | ||
It is an **abstract** module which implements the range request mechanism which can be used by different implementations, like: | ||
* [@tokenizer/http](https://github.com/Borewit/tokenizer-http): An HTTP(S) client | ||
* [@tokenizer/s3](https://github.com/Borewit/tokenizer-s3): An Amazon S3 client | ||
## Compatibility | ||
@@ -43,2 +47,34 @@ This module can be used both in the browser and in [Node.js](https://nodejs.org). | ||
## Range-request-client | ||
The `IRangeRequestClient` defines the interface to map, presumably an HTTP client, to the range request mechanism. | ||
```ts | ||
/** | ||
* Implementation of the range-request-client | ||
*/ | ||
export interface IRangeRequestClient { | ||
/** | ||
* Head request to determine the size and MIME-type of the file | ||
* @return HEAD-request information | ||
*/ | ||
getHeadInfo?(): Promise<IHeadRequestInfo>; | ||
/** | ||
* | ||
* @param method - HTTP method | ||
* @param range - Array of 2 numbers: The range-start and range-end. An integer indicating the beginning and the end of range request in bytes. | ||
* @return Range request response | ||
*/ | ||
getResponse(method: string, range?: [number, number]): Promise<IRangeRequestResponse>; | ||
} | ||
``` | ||
For further details of the interface see: [lib/types.ts](lib/types.ts) | ||
Example implementations of the `IRangeRequestClient` interface: | ||
* [@tokenizer/s3](https://github.com/Borewit/tokenizer-s3/blob/master/lib/s3-request.ts) | ||
* [@tokenizer/http](https://github.com/Borewit/tokenizer-http/blob/master/lib/http-client.ts) | ||
## Licence | ||
@@ -45,0 +81,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28651
501
89