diff --git a/src/RequestManager.test.ts b/src/RequestManager.test.ts index 330b4f5..5667f32 100644 --- a/src/RequestManager.test.ts +++ b/src/RequestManager.test.ts @@ -43,7 +43,7 @@ describe("client-js", () => { const transport = new EventEmitterTransport("foo://unique-uri"); const c = new RequestManager([transport]); return c.connect().then(() => { - expect(() => c.endBatch()).toThrow(); + expect(() => c.stopBatch()).toThrow(); }); }); @@ -86,7 +86,7 @@ describe("client-js", () => { }, }); expect(requests[1]).resolves.toEqual("bar"); - c.endBatch(); + c.stopBatch(); c.close(); }); @@ -115,7 +115,7 @@ describe("client-js", () => { c.request("foo", []), c.request("foo", []), ]; - c.endBatch(); + c.stopBatch(); const [a, b] = await Promise.all(requests); expect(a).toEqual("foo"); expect(b).toEqual("bar"); diff --git a/src/RequestManager.ts b/src/RequestManager.ts index 978a042..6435f8d 100644 --- a/src/RequestManager.ts +++ b/src/RequestManager.ts @@ -98,7 +98,7 @@ class RequestManager { this.batchStarted = true; } - public endBatch(): void { + public stopBatch(): void { if (this.batchStarted === false) { throw new Error("cannot end that which has never started"); } diff --git a/src/index.ts b/src/index.ts index 033065a..8b4eaf9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,34 +30,34 @@ class Client implements IClient { /** * Initiates [[RequestManager.startBatch]] in order to build a batch call. * - * Subsequent calls to [[Client.request]] will be added to the batch. Once endBatch is called, the promises for the - * [[Client.request]] will then be resolved. If the request manager already has a batch in progress, this method - * is a noop. + * Subsequent calls to [[Client.request]] will be added to the batch. Once [[Client.stopBatch]] is called, the + * promises for the [[Client.request]] will then be resolved. If the [[RequestManager]] already has a batch in + * progress, this method is a noop. * * @example * myClient.startBatch(); * myClient.request("foo", ["bar"]).then(() => console.log('foobar')); * myClient.request("foo", ["baz"]).then(() => console.log('foobaz')); - * myClient.endBatch(); + * myClient.stopBatch(); */ public startBatch(): void { return this.requestManager.startBatch(); } /** - * Initiates [[RequestManager.endBatch]] in order to finalize and send the batch to the underlying transport. + * Initiates [[RequestManager.stopBatch]] in order to finalize and send the batch to the underlying transport. * - * [[Client.endBatch]] will send the [[Client.request]] calls made since the last [[Client.startBatch]] call. For that - * reason, [[Client.startBatch]] MUST be called before [[Client.endBatch]]. + * [[Client.stopBatch]] will send the [[Client.request]] calls made since the last [[Client.startBatch]] call. For + * that reason, [[Client.startBatch]] MUST be called before [[Client.stopBatch]]. * * @example * myClient.startBatch(); * myClient.request("foo", ["bar"]).then(() => console.log('foobar')); * myClient.request("foo", ["baz"]).then(() => console.log('foobaz')); - * myClient.endBatch(); + * myClient.stopBatch(); */ - public endBatch(): void { - return this.requestManager.endBatch(); + public stopBatch(): void { + return this.requestManager.stopBatch(); } /**