Skip to content

Latest commit

 

History

History
350 lines (249 loc) · 7.96 KB

File metadata and controls

350 lines (249 loc) · 7.96 KB

Table of contents

index.ts

Interfaces

Dictionary

interface Dictionary<TValue = any> {
    [key: string]: TValue;
}

Type parameters

Name Default
TValue any

Index

[key: string]: TValue;
  • Parameter key - string
  • Type TValue

NoiaRequest

interface NoiaRequest {
    src: string;
}

Properties

Name Type Optional
src string false

NoiaPieceRequest

interface NoiaPieceRequest extends NoiaRequest {
    pieceIndex: number;
}

Extends

NoiaRequest

Properties

Name Type Optional
pieceIndex number false

FileInfo

interface FileInfo {
    piecesCount: number;
    contentLength: number;
    pieceLength: number;
}

Properties

Name Type Optional
piecesCount number false
contentLength number false
pieceLength number false

NoiaEmitter

interface NoiaEmitter {
    addListener<TKey extends keyof NoiaClientEventMap>(eventType: TKey, listener: (event: NoiaClientEventMap[TKey]) => void | Promise<void>): EventSubscription;
    fileInfo: Promise<FileInfo>;
}

Method

addListener<TKey extends keyof NoiaClientEventMap>(eventType: TKey, listener: (event: NoiaClientEventMap[TKey]) => void | Promise<void>): EventSubscription;

Type parameters

Name Constraint
TKey keyof NoiaClientEventMap

Parameters

Name Type
eventType TKey
listener (event: NoiaClientEventMap[TKey]) => void | Promise

Return type

EventSubscription

Properties

Name Type Optional
fileInfo Promise<FileInfo> false

NoiaStreamDto

interface NoiaStreamDto {
    emitter: NoiaEmitter;
    start: () => void;
}

Properties

Name Type Optional
emitter NoiaEmitter false
start () => void false

NoiaClient

interface NoiaClient {
    download(dto: NoiaRequest): Promise<Buffer>;
    downloadPiece(dto: NoiaPieceRequest): Promise<Buffer>;
    stream(dto: NoiaRequest): NoiaStreamDto;
}

Method

download(dto: NoiaRequest): Promise<Buffer>;

Parameters

Name Type
dto NoiaRequest

Return type

Promise

downloadPiece(dto: NoiaPieceRequest): Promise<Buffer>;

Parameters

Name Type
dto NoiaPieceRequest

Return type

Promise

stream(dto: NoiaRequest): NoiaStreamDto;

Parameters

Name Type
dto NoiaRequest

Return type

NoiaStreamDto


NoiaPieceDto

interface NoiaPieceDto {
    index: number;
    data: Buffer;
}

Properties

Name Type Optional
index number false
data Buffer false

NoiaPieceStartDto

interface NoiaPieceStartDto {
    index: number;
    promise: Promise<NodeResult>;
}

Properties

Name Type Optional
index number false
promise Promise false

NoiaClientEventMap

interface NoiaClientEventMap {
    fileInfo: FileInfo;
    fileDone: Buffer;
    pieceDone: NoiaPieceDto;
    pieceStart: NoiaPieceStartDto;
    allPiecesStarted: {};
}

Properties

Name Type Optional
fileInfo FileInfo false
fileDone Buffer false
pieceDone NoiaPieceDto false
pieceStart NoiaPieceStartDto false
allPiecesStarted {} false

PiecePromiseResolver

interface PiecePromiseResolver {
    pieceIndex: number;
    resolve: (result: NodeResult) => void;
    reject: (reason: string) => void;
    done: boolean;
}

Properties

Name Type Optional
pieceIndex number false
resolve (result: NodeResult) => void false
reject (reason: string) => void false
done boolean false

Classes