@rsksmart/rif-storage
Version:
Library integrating distributed storage projects
44 lines (43 loc) • 1.72 kB
TypeScript
/// <reference types="node" />
import { Directory, DirectoryArray, Entry, Provider } from './definitions';
import { Readable } from 'stream';
export declare const FILE_SYMBOL: unique symbol;
export declare const DIRECTORY_SYMBOL: unique symbol;
/**
* Function that marks an object with Symbol signaling that it is a Directory object.
*
* @see isFile
* @param obj
*/
export declare function markFile<T>(obj: T): T;
/**
* Function that marks an object with Symbol signaling that it is a File object no matter what
* sort of implementation it is (Readable|Buffer|async generator etc)
*
* @see isDirectory
* @param obj
*/
export declare function markDirectory<T extends Record<string, unknown>>(obj: T): T;
/**
* Verifies if the returned object is a file
*
* @param obj
*/
export declare function isFile(obj: unknown): obj is Entry<any>;
/**
* Verifies if the returned object is a directory
*
* @param obj
*/
export declare function isDirectory(obj: unknown): obj is Directory<any>;
export declare function isTSDirectory<T>(data: unknown, genericTest: (entry: T) => boolean): data is Directory<T>;
export declare function isTSDirectoryArray<T>(data: unknown, genericTest: (entry: T) => boolean): data is DirectoryArray<T>;
export declare function isReadable(entry: unknown): entry is Readable;
export declare function isReadableOrBuffer(entry: unknown): entry is Readable | Buffer;
export declare function detectAddress(address: string): Provider | false;
/**
* Fetches last item of the async iterable.
* @param iter
*/
export declare function lastAsyncIterItem<T>(iter: AsyncIterable<T>): Promise<T | undefined>;
export declare function arrayFromAsyncIter<T>(iter: AsyncIterable<T>): Promise<T[]>;