Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tokenizer/range

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tokenizer/range - npm Package Compare versions

Comparing version 0.9.0 to 0.10.0

6

lib/range-request-factory.js

@@ -21,3 +21,7 @@ import { RangeRequestTokenizer, roundRange } from './range-request-tokenizer.js';

}
return new RangeRequestTokenizer(this.rangeRequestClient, headRequestInfo, this.config.minimumChunkSize);
return new RangeRequestTokenizer(this.rangeRequestClient, {
fileInfo: headRequestInfo,
minimumChunkSize: this.config.minimumChunkSize,
abortSignal: config?.abortSignal
});
}

@@ -24,0 +28,0 @@ /**

11

lib/range-request-tokenizer.d.ts
import { AbstractTokenizer, type IReadChunkOptions } from 'strtok3';
import type { IContentRangeType, IHeadRequestInfo, IRangeRequestClient } from './types.js';
interface IRangeRequestTokenizerOptions {
fileInfo: IHeadRequestInfo;
minimumChunkSize: number;
abortSignal?: AbortSignal;
}
/**

@@ -12,6 +17,5 @@ * RangeRequestTokenizer is tokenizer which is an adapter for range-request clients.

private rangeRequestClient;
private minimumChunkSize;
private abortController?;
private options;
private _fileData;
constructor(rangeRequestClient: IRangeRequestClient, fileInfo: IHeadRequestInfo, minimumChunkSize: number, abortController?: AbortController | undefined);
constructor(rangeRequestClient: IRangeRequestClient, options: IRangeRequestTokenizerOptions);
/**

@@ -46,1 +50,2 @@ * Read portion from stream

export declare function parseContentRange(contentRange: string): IContentRangeType;
export {};

@@ -13,11 +13,13 @@ import { AbstractTokenizer } from 'strtok3';

export class RangeRequestTokenizer extends AbstractTokenizer {
constructor(rangeRequestClient, fileInfo, minimumChunkSize, abortController) {
super({ fileInfo });
constructor(rangeRequestClient, options) {
super({ fileInfo: options.fileInfo });
this.rangeRequestClient = rangeRequestClient;
this.minimumChunkSize = minimumChunkSize;
this.abortController = abortController;
if (Number.isNaN(minimumChunkSize)) {
this.options = options;
if (Number.isNaN(options.minimumChunkSize)) {
throw new Error('minimumChunkSize must be a number');
}
this._fileData = new ChunkedFileData();
this.options.abortSignal?.addEventListener('abort', () => {
this.abort();
});
}

@@ -89,3 +91,3 @@ /**

async abort() {
this.abortController?.abort();
this.rangeRequestClient.abort();
}

@@ -106,3 +108,3 @@ async loadRange(range) {

// make a difference.
range = roundRange(range, this.minimumChunkSize);
range = roundRange(range, this.options.minimumChunkSize);
// Upper range should not be greater than max file size

@@ -109,0 +111,0 @@ range[1] = Math.min(this.fileInfo.size - 1, range[1]);

import type { IFileInfo } from 'strtok3';
export interface IRangeRequestConfig {
abortController?: AbortController;
abortSignal?: AbortSignal;
timeoutInSec?: number;

@@ -52,2 +52,6 @@ avoidHeadRequests?: boolean;

getResponse(method: string, range?: [number, number]): Promise<IRangeRequestResponse>;
/**
* Abort pending asynchronous operations
*/
abort(): void;
}
{
"name": "@tokenizer/range",
"version": "0.9.0",
"version": "0.10.0",
"description": "Range-request tokenizer adapter",

@@ -5,0 +5,0 @@ "type": "module",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc