Compare commits
No commits in common. "b23289b8eb7f096154da683578a59f3ccc215079" and "d3e45779437964bd0d2d5c03b41196f058100ebb" have entirely different histories.
b23289b8eb
...
d3e4577943
|
@ -2,7 +2,7 @@ import { Client } from "@lumeweb/libkernel-universal";
|
||||||
import { CatOptions, LsOptions, StatOptions } from "@helia/unixfs";
|
import { CatOptions, LsOptions, StatOptions } from "@helia/unixfs";
|
||||||
interface AbortableGenerator {
|
interface AbortableGenerator {
|
||||||
abort: () => void;
|
abort: () => void;
|
||||||
iterable: () => AsyncIterable<Uint8Array>;
|
iterable: AsyncGenerator<object>;
|
||||||
}
|
}
|
||||||
export declare class IPFSClient extends Client {
|
export declare class IPFSClient extends Client {
|
||||||
ready(): Promise<any>;
|
ready(): Promise<any>;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"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,MAAM,aAAa,CAAC,UAAU,CAAC,CAAC;CAC3C;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;CA4C/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"}
|
|
@ -20,7 +20,7 @@ export class IPFSClient extends Client {
|
||||||
return this.callModuleReturn("getActivePeers");
|
return this.callModuleReturn("getActivePeers");
|
||||||
}
|
}
|
||||||
connectModuleGenerator(method, data) {
|
connectModuleGenerator(method, data) {
|
||||||
let pipe = defer();
|
const pipe = defer();
|
||||||
let done = false;
|
let done = false;
|
||||||
const [update, result] = this.connectModule(method, data, (item) => {
|
const [update, result] = this.connectModule(method, data, (item) => {
|
||||||
pipe.resolve(item);
|
pipe.resolve(item);
|
||||||
|
@ -32,24 +32,15 @@ export class IPFSClient extends Client {
|
||||||
})();
|
})();
|
||||||
return {
|
return {
|
||||||
abort() {
|
abort() {
|
||||||
update("abort");
|
update();
|
||||||
},
|
},
|
||||||
iterable() {
|
// @ts-ignore
|
||||||
return {
|
iterable: async function* () {
|
||||||
[Symbol.asyncIterator]() {
|
// @ts-ignore
|
||||||
return {
|
const iterator = (await pipe.promise)[Symbol.asyncIterator]();
|
||||||
async next() {
|
for await (const value of iterator) {
|
||||||
const chunk = await pipe.promise;
|
yield value;
|
||||||
update("next");
|
}
|
||||||
pipe = defer();
|
|
||||||
return {
|
|
||||||
value: chunk,
|
|
||||||
done: true,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
32
src/index.ts
32
src/index.ts
|
@ -4,7 +4,7 @@ import { CatOptions, LsOptions, StatOptions } from "@helia/unixfs";
|
||||||
|
|
||||||
interface AbortableGenerator {
|
interface AbortableGenerator {
|
||||||
abort: () => void;
|
abort: () => void;
|
||||||
iterable: () => AsyncIterable<Uint8Array>;
|
iterable: AsyncGenerator<object>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class IPFSClient extends Client {
|
export class IPFSClient extends Client {
|
||||||
|
@ -36,7 +36,7 @@ export class IPFSClient extends Client {
|
||||||
method: string,
|
method: string,
|
||||||
data: any
|
data: any
|
||||||
): AbortableGenerator {
|
): AbortableGenerator {
|
||||||
let pipe = defer<Uint8Array>();
|
const pipe = defer();
|
||||||
|
|
||||||
let done = false;
|
let done = false;
|
||||||
|
|
||||||
|
@ -52,27 +52,15 @@ export class IPFSClient extends Client {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
abort() {
|
abort() {
|
||||||
update("abort");
|
update();
|
||||||
},
|
},
|
||||||
|
// @ts-ignore
|
||||||
iterable(): AsyncIterable<Uint8Array> {
|
iterable: async function* (): AsyncGenerator<object> {
|
||||||
return {
|
// @ts-ignore
|
||||||
[Symbol.asyncIterator]() {
|
const iterator = (await pipe.promise)[Symbol.asyncIterator]();
|
||||||
return {
|
for await (const value of iterator) {
|
||||||
async next(): Promise<IteratorResult<Uint8Array>> {
|
yield value as object;
|
||||||
const chunk = await pipe.promise;
|
}
|
||||||
update("next");
|
|
||||||
|
|
||||||
pipe = defer();
|
|
||||||
|
|
||||||
return {
|
|
||||||
value: chunk,
|
|
||||||
done: true as const,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue