ldap-async
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -40,2 +40,3 @@ /// <reference types="node" /> | ||
protected poolQueue: ((client: LdapClient) => void)[]; | ||
protected closeRequest?: Function; | ||
constructor(config?: LdapConfig); | ||
@@ -45,2 +46,3 @@ protected connect(): Promise<LdapClient>; | ||
protected release(client: LdapClient): void; | ||
close(): Promise<void>; | ||
wait(): Promise<void>; | ||
@@ -47,0 +49,0 @@ get<T = any>(base: string, options?: SearchOptions, controls?: Control | Control[]): Promise<T>; |
@@ -104,2 +104,3 @@ "use strict"; | ||
release(client) { | ||
var _a; | ||
client.busy = false; | ||
@@ -109,3 +110,18 @@ const nextInQueue = this.poolQueue.shift(); | ||
nextInQueue(client); | ||
else if (this.clients.every(c => !c.busy)) | ||
(_a = this.closeRequest) === null || _a === void 0 ? void 0 : _a.call(this); | ||
} | ||
async close() { | ||
if (this.closeRequest) | ||
return; | ||
if (this.clients.some(c => c.busy)) { | ||
await new Promise(resolve => { | ||
this.closeRequest = resolve; | ||
}); | ||
this.closeRequest = undefined; | ||
} | ||
for (const client of this.clients) | ||
client.unbind(); | ||
this.clients = []; | ||
} | ||
async wait() { | ||
@@ -112,0 +128,0 @@ let loops = 0; |
{ | ||
"name": "ldap-async", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "A wrapper around ldapjs to provide promises, pooling, config by environment, and other conveniences.", | ||
@@ -24,3 +24,3 @@ "exports": { | ||
"build": "rm -rf dist && tsc", | ||
"mocha": "mocha -r ts-node/register test/**/*.ts --exit", | ||
"mocha": "mocha -r ts-node/register test/**/*.ts", | ||
"test": "./test.sh" | ||
@@ -37,5 +37,5 @@ }, | ||
"chai": "^4.2.0", | ||
"eslint-config-standard-with-typescript": "^21.0.1", | ||
"eslint-config-standard-with-typescript": "^22.0.0", | ||
"image-size": "^1.0.1", | ||
"mocha": "^9.0.3", | ||
"mocha": "^10.0.0", | ||
"ts-node": "^10.2.0", | ||
@@ -42,0 +42,0 @@ "typescript": "^4.3.5" |
@@ -187,2 +187,5 @@ # Overview | ||
## Close the pool | ||
Generally you want to let the pool do its thing for the entire life of your process, but if you are sure you're done with it, you can call `await client.close()` and it will wait for all existing requests to finish, then empty the pool so that everything can be garbage collected. The pool is still valid, so if you make another request, the pool will open back up and work normally. | ||
## Typescript | ||
@@ -189,0 +192,0 @@ This library is written in typescript and provides its own types. For added convenience, methods that return |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32765
511
201