import { AbstractAttachment } from './attachment'; import { Blob, BlobSeekWhence, BlobStream } from '..'; /** AbstractBlobStream implementation. */ export abstract class AbstractBlobStream extends BlobStream { protected constructor( blob: Blob, public attachment: AbstractAttachment, ) { super(blob); } get length(): Promise { return this.internalGetLength(); } async close(): Promise { return await this.internalClose(); } async cancel(): Promise { return await this.internalCancel(); } async seek(offset: number, whence?: BlobSeekWhence): Promise { return await this.internalSeek(offset, whence); } async read(buffer: Buffer): Promise { return await this.internalRead(buffer); } async write(buffer: Buffer): Promise { return await this.internalWrite(buffer); } protected abstract internalGetLength(): Promise; protected abstract internalClose(): Promise; protected abstract internalCancel(): Promise; protected abstract internalSeek(offset: number, whence?: BlobSeekWhence): Promise; protected abstract internalRead(buffer: Buffer): Promise; protected abstract internalWrite(buffer: Buffer): Promise; }