From ebd2ddf4a27a990f25e1977c72cd4fbdbf403a00 Mon Sep 17 00:00:00 2001 From: Phil Gore Date: Sat, 11 Sep 2021 12:59:34 -0500 Subject: [PATCH] figuring out why the tests list this as not a function Signed-off-by: Phil Gore --- .../src/ldap/client.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/plugins/catalog-backend-module-ldap/src/ldap/client.ts b/plugins/catalog-backend-module-ldap/src/ldap/client.ts index 6dae1839ce..d859c5e08b 100644 --- a/plugins/catalog-backend-module-ldap/src/ldap/client.ts +++ b/plugins/catalog-backend-module-ldap/src/ldap/client.ts @@ -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 { + 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; } }