reduct-js
Version:
ReductStore Client SDK for Javascript/NodeJS/Typescript
55 lines (54 loc) • 1.73 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
import { Buffer } from "buffer";
import { WriteOptions } from "./Bucket";
import { HttpClient } from "./http/HttpClient";
export type LabelMap = Record<string, string | number | boolean | bigint>;
/**
* Represents a record in an entry for reading
*/
export declare class ReadableRecord {
readonly time: bigint;
readonly size: bigint;
readonly last: boolean;
readonly stream: ReadableStream<Uint8Array>;
readonly labels: LabelMap;
readonly contentType: string | undefined;
private readonly arrayBuffer;
/**
* Constructor which should be call from Bucket
* @internal
*/
constructor(time: bigint, size: bigint, last: boolean, head: boolean, stream: ReadableStream<Uint8Array>, labels: LabelMap, contentType?: string);
/**
* Read content of record
*/
read(): Promise<Buffer>;
/**
* Read content of record and convert to string
*/
readAsString(): Promise<string>;
}
/**
* Represents a record in an entry for writing
*/
export declare class WritableRecord {
private readonly bucketName;
private readonly entryName;
private readonly httpClient;
private readonly options;
/**
* Constructor for stream
* @internal
*/
constructor(bucketName: string, entryName: string, options: WriteOptions, httpClient: HttpClient);
/**
* Write data to record asynchronously
* @param data stream or buffer with data
* @param size size of data in bytes (only for streams)
*/
write(data: Buffer | string | ReadableStream<Uint8Array> | {
readable: boolean;
read: () => any;
}, size?: bigint | number): Promise<void>;
}