Comparing version 5.0.2 to 5.0.3
@@ -91,7 +91,8 @@ "use strict"; | ||
this.stream = (0, tls_1.connect)(resolved); | ||
this.stream.once("secureConnect", this.initFailoverDetector.bind(this)); | ||
} | ||
else { | ||
this.stream = (0, net_1.createConnection)(resolved); | ||
this.stream.once("connect", this.initFailoverDetector.bind(this)); | ||
} | ||
this.stream.once("connect", () => this.initFailoverDetector()); | ||
this.stream.once("error", (err) => { | ||
@@ -98,0 +99,0 @@ this.firstError = err; |
export { default } from "./Redis"; | ||
export type { default as Redis } from "./Redis"; | ||
export { default as Cluster } from "./cluster"; | ||
@@ -3,0 +4,0 @@ /** |
@@ -128,10 +128,9 @@ /// <reference types="node" /> | ||
*/ | ||
monitor(callback: Callback<Redis>): Promise<Redis>; | ||
monitor(callback?: Callback<Redis>): Promise<Redis>; | ||
/** | ||
* Send a command to Redis | ||
* | ||
* This method is used internally by the `Redis#set`, `Redis#lpush` etc. | ||
* Most of the time you won't invoke this method directly. | ||
* However when you want to send a command that is not supported by ioredis yet, | ||
* this command will be useful. | ||
* This method is used internally and in most cases you should not | ||
* use it directly. If you need to send a command that is not supported | ||
* by the library, you can use the `call` method: | ||
* | ||
@@ -141,14 +140,5 @@ * ```js | ||
* | ||
* // Use callback | ||
* const get = new Command('get', ['foo'], 'utf8', function (err, result) { | ||
* console.log(result); | ||
* }); | ||
* redis.sendCommand(get); | ||
* | ||
* // Use promise | ||
* const set = new Command('set', ['foo', 'bar'], 'utf8'); | ||
* set.promise.then(function (result) { | ||
* console.log(result); | ||
* }); | ||
* redis.sendCommand(set); | ||
* redis.call('set', 'foo', 'bar'); | ||
* // or | ||
* redis.call(['set', 'foo', 'bar']); | ||
* ``` | ||
@@ -155,0 +145,0 @@ * |
@@ -138,5 +138,15 @@ "use strict"; | ||
_this.stream = stream; | ||
if (typeof options.keepAlive === "number") { | ||
stream.setKeepAlive(true, options.keepAlive); | ||
if (options.noDelay) { | ||
stream.setNoDelay(true); | ||
} | ||
// Node ignores setKeepAlive before connect, therefore we wait for the event: | ||
// https://github.com/nodejs/node/issues/31663 | ||
if (typeof options.keepAlive === 'number') { | ||
if (stream.connecting) { | ||
stream.once(CONNECT_EVENT, () => stream.setKeepAlive(true, options.keepAlive)); | ||
} | ||
else { | ||
stream.setKeepAlive(true, options.keepAlive); | ||
} | ||
} | ||
if (stream.connecting) { | ||
@@ -190,5 +200,2 @@ stream.once(CONNECT_EVENT, eventHandler.connectHandler(_this)); | ||
} | ||
if (options.noDelay) { | ||
stream.setNoDelay(true); | ||
} | ||
const connectionReadyHandler = function () { | ||
@@ -281,3 +288,4 @@ _this.removeListener("close", connectionCloseHandler); | ||
}); | ||
return (0, standard_as_callback_1.default)(new Promise(function (resolve) { | ||
return (0, standard_as_callback_1.default)(new Promise(function (resolve, reject) { | ||
monitorInstance.once("error", reject); | ||
monitorInstance.once("monitoring", function () { | ||
@@ -291,6 +299,5 @@ resolve(monitorInstance); | ||
* | ||
* This method is used internally by the `Redis#set`, `Redis#lpush` etc. | ||
* Most of the time you won't invoke this method directly. | ||
* However when you want to send a command that is not supported by ioredis yet, | ||
* this command will be useful. | ||
* This method is used internally and in most cases you should not | ||
* use it directly. If you need to send a command that is not supported | ||
* by the library, you can use the `call` method: | ||
* | ||
@@ -300,14 +307,5 @@ * ```js | ||
* | ||
* // Use callback | ||
* const get = new Command('get', ['foo'], 'utf8', function (err, result) { | ||
* console.log(result); | ||
* }); | ||
* redis.sendCommand(get); | ||
* | ||
* // Use promise | ||
* const set = new Command('set', ['foo', 'bar'], 'utf8'); | ||
* set.promise.then(function (result) { | ||
* console.log(result); | ||
* }); | ||
* redis.sendCommand(set); | ||
* redis.call('set', 'foo', 'bar'); | ||
* // or | ||
* redis.call(['set', 'foo', 'bar']); | ||
* ``` | ||
@@ -355,4 +353,3 @@ * | ||
} | ||
if (command.name === "quit" && | ||
this.offlineQueue.length === 0) { | ||
if (command.name === "quit" && this.offlineQueue.length === 0) { | ||
this.disconnect(); | ||
@@ -359,0 +356,0 @@ command.resolve(Buffer.from("OK")); |
@@ -198,3 +198,3 @@ "use strict"; | ||
if (self.options.monitor) { | ||
self.call("monitor"); | ||
self.call("monitor").then(() => self.setStatus("monitoring"), (error) => self.emit("error", error)); | ||
const { sendCommand } = self; | ||
@@ -211,3 +211,2 @@ self.sendCommand = function (command) { | ||
}); | ||
self.setStatus("monitoring"); | ||
return; | ||
@@ -214,0 +213,0 @@ } |
{ | ||
"name": "ioredis", | ||
"version": "5.0.2", | ||
"version": "5.0.3", | ||
"description": "A robust, performance-focused and full-featured Redis client for Node.js.", | ||
@@ -60,2 +60,3 @@ "main": "./built/index.js", | ||
"@types/chai": "^4.3.0", | ||
"@types/chai-as-promised": "^7.1.5", | ||
"@types/debug": "^4.1.5", | ||
@@ -62,0 +63,0 @@ "@types/lodash.defaults": "^4.2.6", |
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
671522
30
14776