UNPKG

@solid/community-server

Version:

Community Solid Server: an open and modular implementation of the Solid specifications

33 lines (32 loc) 1.3 kB
import type { Readable, TransformCallback, TransformOptions } from 'node:stream'; import { Transform } from 'node:stream'; export interface SliceStreamOptions extends TransformOptions { start: number; end?: number; size?: number; } /** * A stream that slices a part out of another stream. * `start` and `end` are inclusive. * If `end` is not defined it is until the end of the stream. * * Negative `start` values can be used to instead slice that many streams off the end of the stream. * This requires the `size` field to be defined. * * Both object and non-object streams are supported. * This needs to be explicitly specified, * as the class makes no assumptions based on the object mode of the source stream. */ export declare class SliceStream extends Transform { protected readonly source: Readable; protected remainingSkip: number; protected remainingRead: number; constructor(source: Readable, options: SliceStreamOptions); _transform(chunk: unknown, encoding: BufferEncoding, callback: TransformCallback): void; protected binarySlice(chunk: Buffer): void; protected objectSlice(chunk: unknown): void; /** * Stop piping the source stream and close everything once the slice is finished. */ protected checkEnd(): void; }