Use Typedoc comment style

This commit is contained in:
Franck Royer 2021-05-10 15:53:05 +10:00
parent b4f31dd5e8
commit 40fd7ff365
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
9 changed files with 65 additions and 5 deletions

View File

@ -42,6 +42,7 @@
"mplex", "mplex",
"muxed", "muxed",
"muxer", "muxer",
"mvps",
"nodekey", "nodekey",
"peerhave", "peerhave",
"prettierignore", "prettierignore",

View File

@ -2,6 +2,13 @@ import { Reader } from 'protobufjs/minimal';
import * as proto from '../../proto/chat/v2/chat_message'; import * as proto from '../../proto/chat/v2/chat_message';
/**
* ChatMessage is used by the various show case waku apps that demonstrates
* waku used as the network layer for chat group applications.
*
* This is included to help building PoC and MVPs. Apps that aim to be
* production ready should use a more appropriate data structure.
*/
export class ChatMessage { export class ChatMessage {
public constructor(public proto: proto.ChatMessage) {} public constructor(public proto: proto.ChatMessage) {}
@ -23,11 +30,19 @@ export class ChatMessage {
}); });
} }
/**
* Decode a protobuf payload to a ChatMessage.
* @param bytes The payload to decode.
*/
static decode(bytes: Uint8Array): ChatMessage { static decode(bytes: Uint8Array): ChatMessage {
const protoMsg = proto.ChatMessage.decode(Reader.create(bytes)); const protoMsg = proto.ChatMessage.decode(Reader.create(bytes));
return new ChatMessage(protoMsg); return new ChatMessage(protoMsg);
} }
/**
* Encode this ChatMessage to a byte array, to be used as a protobuf payload.
* @returns The encoded payload.
*/
encode(): Uint8Array { encode(): Uint8Array {
return proto.ChatMessage.encode(this.proto).finish(); return proto.ChatMessage.encode(this.proto).finish();
} }

View File

@ -1,3 +1,8 @@
/**
* @hidden
* @module
*/
import Gossipsub from 'libp2p-gossipsub'; import Gossipsub from 'libp2p-gossipsub';
import { Heartbeat } from 'libp2p-gossipsub/src/heartbeat'; import { Heartbeat } from 'libp2p-gossipsub/src/heartbeat';
import { shuffle } from 'libp2p-gossipsub/src/utils'; import { shuffle } from 'libp2p-gossipsub/src/utils';

View File

@ -10,15 +10,21 @@ import { HistoryRPC } from './history_rpc';
export const StoreCodec = '/vac/waku/store/2.0.0-beta3'; export const StoreCodec = '/vac/waku/store/2.0.0-beta3';
/**
* Implements the [Waku v2 Store protocol](https://rfc.vac.dev/spec/13/).
*/
export class WakuStore { export class WakuStore {
constructor(public libp2p: Libp2p) {} constructor(public libp2p: Libp2p) {}
/** /**
* Retrieve history from given peer * Query given peer using Waku Store.
* @param peerId *
* @param contentTopics * @param peerId The peer to query.
* @param pubsubTopic * @param contentTopics The content topics to retrieve, leave empty to
* @throws if not able to reach peer * retrieve all messages.
* @param pubsubTopic The pubsub topic to retrieve. Currently, all waku nodes
* use the same pubsub topic. This is reserved for future applications.
* @throws If not able to reach the peer to query.
*/ */
async queryHistory( async queryHistory(
peerId: PeerId, peerId: PeerId,

View File

@ -1,3 +1,10 @@
/**
* Various promisify of fs utilities.
*
* @hidden
* @module
*/
import fs, { promises as asyncFs } from 'fs'; import fs, { promises as asyncFs } from 'fs';
import { promisify } from 'util'; import { promisify } from 'util';

View File

@ -1,2 +1,9 @@
/**
* Some constants for test purposes.
*
* @hidden
* @module
*/
export const NOISE_KEY_1 = Buffer.alloc(32, 1); export const NOISE_KEY_1 = Buffer.alloc(32, 1);
export const NOISE_KEY_2 = Buffer.alloc(32, 1); export const NOISE_KEY_2 = Buffer.alloc(32, 1);

View File

@ -1,3 +1,10 @@
/**
* A collection of tools to test the WakuJS library.
*
* @hidden
* @module
*/
export * from './async_fs'; export * from './async_fs';
export * from './constants'; export * from './constants';
export * from './log_file'; export * from './log_file';

View File

@ -1,3 +1,10 @@
/**
* Utilities to make it help check nim-waku logs.
*
* @hidden
* @module
*/
import { Context } from 'mocha'; import { Context } from 'mocha';
import pTimeout from 'p-timeout'; import pTimeout from 'p-timeout';
import { Tail } from 'tail'; import { Tail } from 'tail';

View File

@ -1,3 +1,8 @@
/**
* @hidden
* @module
*/
import { ChildProcess, spawn } from 'child_process'; import { ChildProcess, spawn } from 'child_process';
import { randomInt } from 'crypto'; import { randomInt } from 'crypto';