npm.io
0.0.36 • Published 5 years ago

@cuser/reader

Licence
MIT
Version
0.0.36
Deps
1
Size
19 kB
Vulns
0
Weekly
0
Stars
4

cuser logo

Status

codecov npm npm-downloads

Class: CuserReader

Hierarchy

  • CuserReader

Index

Constructors
Methods

Constructors

constructor

+ new CuserReader(core: CuserCore, peerId: string | Promise<string>, opts?: CuserReaderOptions): CuserReader

Defined in reader/reader.js:32

Parameters:
Name Type Default value
core CuserCore -
peerId string | Promise<string> -
opts CuserReaderOptions {}

Returns: CuserReader

Methods

_resolveRootMessage

▸ Private_resolveRootMessage(topicId: string): Promise<string>

Defined in reader/reader.js:118

Get the root message for a certain topicId

Parameters:
Name Type
topicId string

Returns: Promise<string>


getMessage

▸ getMessage(cid: string): Promise<GraphMessage>

Defined in reader/reader.js:108

Gets the message from ipfs using the CID given by parameter

Parameters:
Name Type
cid string

Returns: Promise<GraphMessage>


getMessages

▸ getMessages(topicId: string, opts: CuserReaderMessagesIteratorOptions): Promise<CuserReaderMessageIteratorResult[]> | AsyncIterable<CuserReaderMessageIteratorResult>

Defined in reader/reader.js:76

Gets messages from ipfs layer

example

Array
const messages = reader.getMessages('custom_topic_id');
console.log(messages);
Iterator
const messages = reader.getMessages('custom_topic_id', {
  iterator: true,
});
for await (let value of messages) {
  console.log(value);
}
Parameters:
Name Type
topicId string
opts CuserReaderMessagesIteratorOptions

Returns: Promise<CuserReaderMessageIteratorResult[]> | AsyncIterable<CuserReaderMessageIteratorResult>