various small README and comment fixes (#10)

* various small README and comment fixes

* add async/sync variants with comments
This commit is contained in:
Vaclav Pavlin 2025-03-26 12:46:39 +01:00 committed by GitHub
parent f77978cd63
commit 5d2f3f6603
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 6 deletions

View File

@ -55,7 +55,7 @@ const codex = new Codex("http://localhost:3000");
To use a module, you need to use the await syntax. If the module is not loaded yet, it will be imported first and then cached in memory. To use a module, you need to use the await syntax. If the module is not loaded yet, it will be imported first and then cached in memory.
```js ```js
const marketplace = await codex.marketplace; const marketplace = await codex.marketplace();
``` ```
### Error handling ### Error handling
@ -97,7 +97,11 @@ The following API assume that you have already a marketplace module loaded, exam
```js ```js
const codex = new Codex("http://localhost:3000"); const codex = new Codex("http://localhost:3000");
// When using the async api
const marketplace = await codex.marketplace(); const marketplace = await codex.marketplace();
// When using the sync api
const marketplace = codex.marketplace
``` ```
#### activeSlots() #### activeSlots()
@ -241,7 +245,11 @@ The following API assume that you have already a data module loaded, example:
```js ```js
const codex = new Codex("http://localhost:3000"); const codex = new Codex("http://localhost:3000");
const data = await codex.data; // When using the async api
const data = await codex.data();
// When using the sync api
const data = codex.data
``` ```
#### cids #### cids
@ -342,7 +350,11 @@ The following API assume that you have already a node module loaded, example:
```js ```js
const codex = new Codex("http://localhost:3000"); const codex = new Codex("http://localhost:3000");
const data = await codex.debug; // When using the async api
const data = await codex.debug();
// When using the sync api
const data = codex.debug
``` ```
#### setLogLevel #### setLogLevel
@ -376,7 +388,11 @@ The following API assume that you have already a node module loaded, example:
```js ```js
const codex = new Codex("http://localhost:3000"); const codex = new Codex("http://localhost:3000");
const node = await codex.node; // When using the async api
const node = await codex.node();
// When using the sync api
const node = codex.node
``` ```
#### spr #### spr

View File

@ -127,8 +127,8 @@ export class CodexData {
} }
/** /**
* Download a file from the network in a streaming manner. * Download a file from the network to the local node if it's not available locally.
* If the file is not available locally, it will be retrieved from other nodes in the network if able. * Note: Download is performed async. Call can return before download is completed.
*/ */
async networkDownload(cid: string): Promise<SafeValue<NetworkDownloadResponse>> { async networkDownload(cid: string): Promise<SafeValue<NetworkDownloadResponse>> {
const url = this.url + Api.config.prefix + `/data/${cid}/network`; const url = this.url + Api.config.prefix + `/data/${cid}/network`;