-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use native Promise instead of Bluebird, and allow users to swit…
…ch back. BREAKING CHANGE: This change makes all the code that rely on the features provided by Bluebird not working anymore. For example, `redis.get('foo').timeout(500)` now should be failed since the native Promise doesn't support the `timeout` method. You can switch back to the Bluebird implementation by setting `Redis.Promise`: ``` const Redis = require('ioredis') Redis.Promise = require('bluebird') const redis = new Redis() // Use bluebird assert.equal(redis.get().constructor, require('bluebird')) // You can change the Promise implementation at any time: Redis.Promise = global.Promise assert.equal(redis.get().constructor, global.Promise) ```
- Loading branch information
Showing
20 changed files
with
185 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
exports.isPromise = function (obj) { | ||
return !!obj && | ||
(typeof obj === 'object' || typeof obj === 'function') && | ||
typeof obj.then === 'function' | ||
} | ||
|
||
let promise = global.Promise | ||
|
||
exports.get = function () { | ||
return promise | ||
} | ||
|
||
exports.set = function (lib) { | ||
if (typeof lib !== 'function') { | ||
throw new Error(`Provided Promise must be a function, got ${lib}`) | ||
} | ||
|
||
promise = lib | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.