Skip to content

Commit 477f3f0

Browse files
Fix Comment Type and Change iterationHelper as a private member
1 parent d28fe85 commit 477f3f0

File tree

5 files changed

+21
-26
lines changed

5 files changed

+21
-26
lines changed

lib/src/tasks/PageIterator.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ export declare class PageIterator {
5252
*/
5353
constructor(client: Client, pageCollection: PageCollection, callback: PageIteratorCallback);
5454
/**
55+
* @private
5556
* Iterates over a collection by enqueuing entries one by one and kicking the callback with the enqueued entry
5657
* @return A boolean indicating the continue flag to process next page
5758
*/
58-
iterationHelper(): boolean;
59+
private iterationHelper;
5960
/**
6061
* @private
6162
* @async
@@ -72,7 +73,7 @@ export declare class PageIterator {
7273
iterate(): Promise<any>;
7374
/**
7475
* @async
75-
* This internally calls the iterate method, Its juts for more readability.
76+
* This internally calls the iterate method, It's just for more readability.
7677
* @return A Promise that resolves to nothing on completion and throws error incase of any discrepancy
7778
*/
7879
resume(): Promise<any>;

lib/src/tasks/PageIterator.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/tasks/PageIterator.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/tasks/PageIterator.ts

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,32 +69,24 @@ describe("Constructor", function () {
6969
});
7070
});
7171

72-
describe("iterationHelper", function() {
73-
it("Should iterate over complete collection", () => {
72+
describe("iterate", function() {
73+
it("Should iterate over a complete collection without nextLink", async () => {
7474
truthyCallbackCounter = 10;
7575
let pageIterator = new PageIterator(client, getPageCollection(), truthyCallbackWithCounter);
76-
assert.isTrue(pageIterator.iterationHelper());
77-
assert.equal(truthyCallbackCounter, 0);
78-
});
79-
80-
it("Should break in the middle of the iteration, this is done by returning red flag from the callback", () => {
81-
halfWayCallbackCounter = 5;
82-
let pageIterator = new PageIterator(client, getPageCollection(), halfWayCallback);
83-
assert.isFalse(pageIterator.iterationHelper());
84-
assert.equal(halfWayCallbackCounter, 0);
76+
try {
77+
await pageIterator.iterate();
78+
assert.equal(truthyCallbackCounter, 0);
79+
} catch (error) {
80+
throw error;
81+
}
8582
});
8683

87-
it("Should return false for iterating over empty collection", () => {
84+
it("Should not iterate over an empty collection", async () => {
8885
let pageIterator = new PageIterator(client, getEmptyPageCollection(), truthyCallback);
89-
assert.isFalse(pageIterator.iterationHelper());
90-
});
91-
});
92-
93-
describe("iterate", function() {
94-
it("Should iterate over a complete collection without nextLink", async () => {
95-
let pageIterator = new PageIterator(client, getPageCollection(), truthyCallback);
86+
halfWayCallbackCounter = 1;
9687
try {
9788
await pageIterator.iterate();
89+
assert.equal(halfWayCallbackCounter, 1);
9890
} catch (error) {
9991
throw error;
10092
}
@@ -126,4 +118,4 @@ describe("resume", function() {
126118
throw error;
127119
}
128120
});
129-
});
121+
});

src/tasks/PageIterator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ export class PageIterator {
6969
}
7070

7171
/**
72+
* @private
7273
* Iterates over a collection by enqueuing entries one by one and kicking the callback with the enqueued entry
7374
* @return A boolean indicating the continue flag to process next page
7475
*/
75-
iterationHelper(): boolean {
76+
private iterationHelper(): boolean {
7677
let self = this;
7778
if (self.collection === undefined || self.collection.length === 0) {
7879
return false;
@@ -127,7 +128,7 @@ export class PageIterator {
127128

128129
/**
129130
* @async
130-
* This internally calls the iterate method, Its juts for more readability.
131+
* This internally calls the iterate method, It's just for more readability.
131132
* @return A Promise that resolves to nothing on completion and throws error incase of any discrepancy
132133
*/
133134
async resume(): Promise<any> {

0 commit comments

Comments
 (0)