From b23289b8eb7f096154da683578a59f3ccc215079 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 9 Apr 2023 16:20:01 -0400 Subject: [PATCH] *Update dist --- dist/index.d.ts | 2 +- dist/index.d.ts.map | 2 +- dist/index.js | 27 ++++++++++++++++++--------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/dist/index.d.ts b/dist/index.d.ts index 3cdb75f..6d58c72 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -2,7 +2,7 @@ import { Client } from "@lumeweb/libkernel-universal"; import { CatOptions, LsOptions, StatOptions } from "@helia/unixfs"; interface AbortableGenerator { abort: () => void; - iterable: AsyncGenerator; + iterable: () => AsyncIterable; } export declare class IPFSClient extends Client { ready(): Promise; diff --git a/dist/index.d.ts.map b/dist/index.d.ts.map index d55895d..d1072ae 100644 --- a/dist/index.d.ts.map +++ b/dist/index.d.ts.map @@ -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,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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 991359c..c89be61 100644 --- a/dist/index.js +++ b/dist/index.js @@ -20,7 +20,7 @@ export class IPFSClient extends Client { return this.callModuleReturn("getActivePeers"); } connectModuleGenerator(method, data) { - const pipe = defer(); + let pipe = defer(); let done = false; const [update, result] = this.connectModule(method, data, (item) => { pipe.resolve(item); @@ -32,15 +32,24 @@ export class IPFSClient extends Client { })(); return { abort() { - update(); + update("abort"); }, - // @ts-ignore - iterable: async function* () { - // @ts-ignore - const iterator = (await pipe.promise)[Symbol.asyncIterator](); - for await (const value of iterator) { - yield value; - } + iterable() { + return { + [Symbol.asyncIterator]() { + return { + async next() { + const chunk = await pipe.promise; + update("next"); + pipe = defer(); + return { + value: chunk, + done: true, + }; + }, + }; + }, + }; }, }; }