figuring out why the tests list this as not a function

Signed-off-by: Phil Gore <pgore@ea.com>
This commit is contained in:
Phil Gore
2021-09-11 12:59:34 -05:00
parent 49776f8479
commit ebd2ddf4a2
@@ -110,13 +110,16 @@ export class LdapClient {
}
/**
* Performs an LDAP search operation, calls a function on each entry to limit memory usage
* Performs an LDAP search operation, creates a generator to limit memory usage
*
* @param dn The fully qualified base DN to search within
* @param options The search options
*/
*searchStreaming(dn: string, options: SearchOptions) {
let queuesize = 25;
*searchStreaming(
dn: string,
options: SearchOptions,
): IterableIterator<SearchEntry> {
let queueSize = 25;
if (options) {
if (
options.paged &&
@@ -124,10 +127,10 @@ export class LdapClient {
typeof options.paged.pageSize === 'number' &&
options.paged.pageSize > 0
) {
queuesize = options.paged.pageSize;
queueSize = options.paged.pageSize;
}
}
const queue: SearchEntry[] = new Array(queuesize);
const queue: SearchEntry[] = new Array(queueSize);
let done = false;
try {
this.client.search(dn, options, (err, res) => {
@@ -161,7 +164,11 @@ export class LdapClient {
throw new Error(`LDAP search at DN "${dn}" failed, ${e.message}`);
}
while (!done && queue.length > 0) {
yield queue.pop();
const res = queue.pop();
if (!res) {
continue;
}
yield res;
}
}