Compare commits
2 Commits
bda0af49fa
...
fe9045cf82
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | fe9045cf82 | |
Derrick Hammer | aad02e4901 |
|
@ -1,13 +1,14 @@
|
|||
import { Client } from "@lumeweb/libkernel-universal";
|
||||
import { CatOptions, LsOptions, StatOptions } from "@helia/unixfs";
|
||||
interface AbortableGenerator {
|
||||
abort: () => void;
|
||||
iterable: AsyncGenerator<object>;
|
||||
}
|
||||
export declare class IPFSClient extends Client {
|
||||
ready(): Promise<any>;
|
||||
stat(cid: string): Promise<any>;
|
||||
ls(cid: string): AbortableGenerator;
|
||||
cat(cid: string): AbortableGenerator;
|
||||
stat(cid: string, options?: Partial<StatOptions>): Promise<any>;
|
||||
ls(cid: string, options?: Partial<LsOptions>): AbortableGenerator;
|
||||
cat(cid: string, options?: Partial<CatOptions>): AbortableGenerator;
|
||||
ipns(cid: string): Promise<string>;
|
||||
activePeers(): Promise<number>;
|
||||
private connectModuleGenerator;
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAW,MAAM,8BAA8B,CAAC;AAG/D,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CAClC;AAED,qBAAa,UAAW,SAAQ,MAAM;IACvB,KAAK;IAIL,IAAI,CAAC,GAAG,EAAE,MAAM;IAItB,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB;IAInC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB;IAI9B,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlC,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C,OAAO,CAAC,sBAAsB;CAgC/B;AAED,eAAO,MAAM,YAAY,8BAGxB,CAAC"}
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAW,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEnE,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CAClC;AAED,qBAAa,UAAW,SAAQ,MAAM;IACvB,KAAK;IAIL,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC;IAItD,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,kBAAkB;IAIjE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,kBAAkB;IAI7D,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlC,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C,OAAO,CAAC,sBAAsB;CAgC/B;AAED,eAAO,MAAM,YAAY,8BAGxB,CAAC"}
|
|
@ -4,14 +4,14 @@ export class IPFSClient extends Client {
|
|||
async ready() {
|
||||
return this.callModuleReturn("ready");
|
||||
}
|
||||
async stat(cid) {
|
||||
return this.callModuleReturn("stat");
|
||||
async stat(cid, options) {
|
||||
return this.callModuleReturn("stat", { options });
|
||||
}
|
||||
ls(cid) {
|
||||
return this.connectModuleGenerator("ls", { cid });
|
||||
ls(cid, options) {
|
||||
return this.connectModuleGenerator("ls", { cid, options });
|
||||
}
|
||||
cat(cid) {
|
||||
return this.connectModuleGenerator("cat", { cid });
|
||||
cat(cid, options) {
|
||||
return this.connectModuleGenerator("cat", { cid, options });
|
||||
}
|
||||
async ipns(cid) {
|
||||
return this.callModuleReturn("ipnsResolve");
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
"p-defer": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@helia/unixfs": "^1.2.1",
|
||||
"@types/node": "^18.0.6",
|
||||
"prettier": "^2.7.1",
|
||||
"typescript": "^5.0.3"
|
||||
|
|
13
src/index.ts
13
src/index.ts
|
@ -1,5 +1,6 @@
|
|||
import { Client, factory } from "@lumeweb/libkernel-universal";
|
||||
import defer from "p-defer";
|
||||
import { CatOptions, LsOptions, StatOptions } from "@helia/unixfs";
|
||||
|
||||
interface AbortableGenerator {
|
||||
abort: () => void;
|
||||
|
@ -11,16 +12,16 @@ export class IPFSClient extends Client {
|
|||
return this.callModuleReturn("ready");
|
||||
}
|
||||
|
||||
public async stat(cid: string) {
|
||||
return this.callModuleReturn("stat");
|
||||
public async stat(cid: string, options?: Partial<StatOptions>) {
|
||||
return this.callModuleReturn("stat", { options });
|
||||
}
|
||||
|
||||
public ls(cid: string): AbortableGenerator {
|
||||
return this.connectModuleGenerator("ls", { cid });
|
||||
public ls(cid: string, options?: Partial<LsOptions>): AbortableGenerator {
|
||||
return this.connectModuleGenerator("ls", { cid, options });
|
||||
}
|
||||
|
||||
public cat(cid: string): AbortableGenerator {
|
||||
return this.connectModuleGenerator("cat", { cid });
|
||||
public cat(cid: string, options?: Partial<CatOptions>): AbortableGenerator {
|
||||
return this.connectModuleGenerator("cat", { cid, options });
|
||||
}
|
||||
|
||||
public async ipns(cid: string): Promise<string> {
|
||||
|
|
Loading…
Reference in New Issue