From b96062b6de37884dd68f7a03f486ccab7c2a6254 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Mon, 10 Jul 2017 15:56:31 +0100 Subject: [PATCH] replace imports of `q` with bluebird ``` find src spec -name '*.js' | xargs perl -i -pe 'if (/require\(.q.\)/) { $_ = "import Promise from '\''bluebird'\'';\n"; }' find src spec -name '*.js' | xargs perl -i -pe 'if (/import q/) { $_ = "import Promise from '\''bluebird'\'';\n"; }' ``` --- package.json | 2 +- spec/TestClient.js | 2 +- spec/integ/matrix-client-crypto.spec.js | 2 +- spec/integ/matrix-client-event-timeline.spec.js | 2 +- spec/integ/matrix-client-opts.spec.js | 2 +- spec/integ/matrix-client-room-timeline.spec.js | 2 +- spec/integ/matrix-client-syncing.spec.js | 2 +- spec/integ/megolm-integ.spec.js | 2 +- spec/test-utils.js | 2 +- spec/unit/crypto/DeviceList.spec.js | 2 +- spec/unit/crypto/algorithms/megolm.spec.js | 2 +- spec/unit/interactive-auth.spec.js | 2 +- spec/unit/matrix-client.spec.js | 2 +- spec/unit/scheduler.spec.js | 2 +- spec/unit/timeline-window.spec.js | 2 +- src/client.js | 2 +- src/crypto/DeviceList.js | 2 +- src/crypto/OutgoingRoomKeyRequestManager.js | 2 +- src/crypto/algorithms/megolm.js | 2 +- src/crypto/algorithms/olm.js | 2 +- src/crypto/index.js | 2 +- src/crypto/olmlib.js | 2 +- src/crypto/store/indexeddb-crypto-store-backend.js | 2 +- src/crypto/store/indexeddb-crypto-store.js | 2 +- src/crypto/store/memory-crypto-store.js | 2 +- src/http-api.js | 2 +- src/interactive-auth.js | 2 +- src/scheduler.js | 2 +- src/store/indexeddb-local-backend.js | 2 +- src/store/indexeddb-remote-backend.js | 2 +- src/store/indexeddb-store-worker.js | 2 +- src/store/indexeddb.js | 2 +- src/store/memory.js | 2 +- src/store/stub.js | 2 +- src/sync.js | 2 +- src/timeline-window.js | 2 +- 36 files changed, 36 insertions(+), 36 deletions(-) diff --git a/package.json b/package.json index ced495795..fc6724e08 100644 --- a/package.json +++ b/package.json @@ -49,9 +49,9 @@ ], "dependencies": { "another-json": "^0.2.0", + "bluebird": "^3.5.0", "browser-request": "^0.3.3", "content-type": "^1.0.2", - "q": "^1.4.1", "regenerator-runtime": "^0.10.5", "request": "^2.53.0" }, diff --git a/spec/TestClient.js b/spec/TestClient.js index 9d757af7d..a4ceebddd 100644 --- a/spec/TestClient.js +++ b/spec/TestClient.js @@ -24,7 +24,7 @@ import sdk from '..'; import testUtils from './test-utils'; import MockHttpBackend from 'matrix-mock-request'; import expect from 'expect'; -import q from 'q'; +import Promise from 'bluebird'; /** * Wrapper for a MockStorageApi, MockHttpBackend and MatrixClient diff --git a/spec/integ/matrix-client-crypto.spec.js b/spec/integ/matrix-client-crypto.spec.js index ced8976f0..b1734e59c 100644 --- a/spec/integ/matrix-client-crypto.spec.js +++ b/spec/integ/matrix-client-crypto.spec.js @@ -31,7 +31,7 @@ import '../olm-loader'; import expect from 'expect'; const sdk = require("../.."); -const q = require("q"); +import Promise from 'bluebird'; const utils = require("../../lib/utils"); const testUtils = require("../test-utils"); const TestClient = require('../TestClient').default; diff --git a/spec/integ/matrix-client-event-timeline.spec.js b/spec/integ/matrix-client-event-timeline.spec.js index a83f9ef00..f8d2b0cc7 100644 --- a/spec/integ/matrix-client-event-timeline.spec.js +++ b/spec/integ/matrix-client-event-timeline.spec.js @@ -1,6 +1,6 @@ "use strict"; import 'source-map-support/register'; -const q = require("q"); +import Promise from 'bluebird'; const sdk = require("../.."); const HttpBackend = require("matrix-mock-request"); const utils = require("../test-utils"); diff --git a/spec/integ/matrix-client-opts.spec.js b/spec/integ/matrix-client-opts.spec.js index 73731a253..b63451f66 100644 --- a/spec/integ/matrix-client-opts.spec.js +++ b/spec/integ/matrix-client-opts.spec.js @@ -6,7 +6,7 @@ const HttpBackend = require("matrix-mock-request"); const utils = require("../test-utils"); import expect from 'expect'; -import q from 'q'; +import Promise from 'bluebird'; describe("MatrixClient opts", function() { const baseUrl = "http://localhost.or.something"; diff --git a/spec/integ/matrix-client-room-timeline.spec.js b/spec/integ/matrix-client-room-timeline.spec.js index 5ac84dc69..af18f1bbb 100644 --- a/spec/integ/matrix-client-room-timeline.spec.js +++ b/spec/integ/matrix-client-room-timeline.spec.js @@ -5,7 +5,7 @@ const EventStatus = sdk.EventStatus; const HttpBackend = require("matrix-mock-request"); const utils = require("../test-utils"); -import q from 'q'; +import Promise from 'bluebird'; import expect from 'expect'; describe("MatrixClient room timelines", function() { diff --git a/spec/integ/matrix-client-syncing.spec.js b/spec/integ/matrix-client-syncing.spec.js index 7fdc6ba28..52cf7c12f 100644 --- a/spec/integ/matrix-client-syncing.spec.js +++ b/spec/integ/matrix-client-syncing.spec.js @@ -7,7 +7,7 @@ const MatrixEvent = sdk.MatrixEvent; const EventTimeline = sdk.EventTimeline; import expect from 'expect'; -import q from 'q'; +import Promise from 'bluebird'; describe("MatrixClient syncing", function() { const baseUrl = "http://localhost.or.something"; diff --git a/spec/integ/megolm-integ.spec.js b/spec/integ/megolm-integ.spec.js index c876be0e0..c3dd8e6f4 100644 --- a/spec/integ/megolm-integ.spec.js +++ b/spec/integ/megolm-integ.spec.js @@ -17,7 +17,7 @@ limitations under the License. "use strict"; const anotherjson = require('another-json'); -const q = require('q'); +import Promise from 'bluebird'; import expect from 'expect'; const utils = require('../../lib/utils'); diff --git a/spec/test-utils.js b/spec/test-utils.js index adb416669..cc90258d6 100644 --- a/spec/test-utils.js +++ b/spec/test-utils.js @@ -1,6 +1,6 @@ "use strict"; import expect from 'expect'; -import q from 'q'; +import Promise from 'bluebird'; // load olm before the sdk if possible import './olm-loader'; diff --git a/spec/unit/crypto/DeviceList.spec.js b/spec/unit/crypto/DeviceList.spec.js index b2129c2e0..6d77cddc8 100644 --- a/spec/unit/crypto/DeviceList.spec.js +++ b/spec/unit/crypto/DeviceList.spec.js @@ -5,7 +5,7 @@ import testUtils from '../../test-utils'; import utils from '../../../lib/utils'; import expect from 'expect'; -import q from 'q'; +import Promise from 'bluebird'; const signedDeviceList = { "failures": {}, diff --git a/spec/unit/crypto/algorithms/megolm.spec.js b/spec/unit/crypto/algorithms/megolm.spec.js index 1383cecbd..4c170dc0a 100644 --- a/spec/unit/crypto/algorithms/megolm.spec.js +++ b/spec/unit/crypto/algorithms/megolm.spec.js @@ -5,7 +5,7 @@ try { } import expect from 'expect'; -import q from 'q'; +import Promise from 'bluebird'; import sdk from '../../../..'; import algorithms from '../../../../lib/crypto/algorithms'; diff --git a/spec/unit/interactive-auth.spec.js b/spec/unit/interactive-auth.spec.js index bdab2b733..6f72785f1 100644 --- a/spec/unit/interactive-auth.spec.js +++ b/spec/unit/interactive-auth.spec.js @@ -16,7 +16,7 @@ limitations under the License. "use strict"; import 'source-map-support/register'; -const q = require("q"); +import Promise from 'bluebird'; const sdk = require("../.."); const utils = require("../test-utils"); diff --git a/spec/unit/matrix-client.spec.js b/spec/unit/matrix-client.spec.js index 4caf54b64..25444365d 100644 --- a/spec/unit/matrix-client.spec.js +++ b/spec/unit/matrix-client.spec.js @@ -1,6 +1,6 @@ "use strict"; import 'source-map-support/register'; -const q = require("q"); +import Promise from 'bluebird'; const sdk = require("../.."); const MatrixClient = sdk.MatrixClient; const utils = require("../test-utils"); diff --git a/spec/unit/scheduler.spec.js b/spec/unit/scheduler.spec.js index 8421cfd2d..f6dcb85e3 100644 --- a/spec/unit/scheduler.spec.js +++ b/spec/unit/scheduler.spec.js @@ -2,7 +2,7 @@ /* eslint new-cap: "off" */ import 'source-map-support/register'; -const q = require("q"); +import Promise from 'bluebird'; const sdk = require("../.."); const MatrixScheduler = sdk.MatrixScheduler; const MatrixError = sdk.MatrixError; diff --git a/spec/unit/timeline-window.spec.js b/spec/unit/timeline-window.spec.js index bb57d0893..b2c038461 100644 --- a/spec/unit/timeline-window.spec.js +++ b/spec/unit/timeline-window.spec.js @@ -1,6 +1,6 @@ "use strict"; import 'source-map-support/register'; -const q = require("q"); +import Promise from 'bluebird'; const sdk = require("../.."); const EventTimeline = sdk.EventTimeline; const TimelineWindow = sdk.TimelineWindow; diff --git a/src/client.js b/src/client.js index 36b574722..059bb669c 100644 --- a/src/client.js +++ b/src/client.js @@ -23,7 +23,7 @@ const PushProcessor = require('./pushprocessor'); * @module client */ const EventEmitter = require("events").EventEmitter; -const q = require("q"); +import Promise from 'bluebird'; const url = require('url'); const httpApi = require("./http-api"); diff --git a/src/crypto/DeviceList.js b/src/crypto/DeviceList.js index 2b608475b..c3bec5c36 100644 --- a/src/crypto/DeviceList.js +++ b/src/crypto/DeviceList.js @@ -21,7 +21,7 @@ limitations under the License. * Manages the list of other users' devices */ -import q from 'q'; +import Promise from 'bluebird'; import DeviceInfo from './deviceinfo'; import olmlib from './olmlib'; diff --git a/src/crypto/OutgoingRoomKeyRequestManager.js b/src/crypto/OutgoingRoomKeyRequestManager.js index d9ac431a0..ab7926fbe 100644 --- a/src/crypto/OutgoingRoomKeyRequestManager.js +++ b/src/crypto/OutgoingRoomKeyRequestManager.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import q from 'q'; +import Promise from 'bluebird'; import utils from '../utils'; diff --git a/src/crypto/algorithms/megolm.js b/src/crypto/algorithms/megolm.js index 61c44e5e0..f495b7182 100644 --- a/src/crypto/algorithms/megolm.js +++ b/src/crypto/algorithms/megolm.js @@ -21,7 +21,7 @@ limitations under the License. * @module crypto/algorithms/megolm */ -const q = require("q"); +import Promise from 'bluebird'; const utils = require("../../utils"); const olmlib = require("../olmlib"); diff --git a/src/crypto/algorithms/olm.js b/src/crypto/algorithms/olm.js index f3c7967eb..f84951177 100644 --- a/src/crypto/algorithms/olm.js +++ b/src/crypto/algorithms/olm.js @@ -20,7 +20,7 @@ limitations under the License. * * @module crypto/algorithms/olm */ -const q = require('q'); +import Promise from 'bluebird'; const utils = require("../../utils"); const olmlib = require("../olmlib"); diff --git a/src/crypto/index.js b/src/crypto/index.js index 8417384b3..002a928fd 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -21,7 +21,7 @@ limitations under the License. */ const anotherjson = require('another-json'); -const q = require("q"); +import Promise from 'bluebird'; import {EventEmitter} from 'events'; const utils = require("../utils"); diff --git a/src/crypto/olmlib.js b/src/crypto/olmlib.js index 7b487b7b4..b365e20e8 100644 --- a/src/crypto/olmlib.js +++ b/src/crypto/olmlib.js @@ -20,7 +20,7 @@ limitations under the License. * Utilities common to olm encryption algorithms */ -const q = require('q'); +import Promise from 'bluebird'; const anotherjson = require('another-json'); const utils = require("../utils"); diff --git a/src/crypto/store/indexeddb-crypto-store-backend.js b/src/crypto/store/indexeddb-crypto-store-backend.js index 39c286e49..b9fb9599d 100644 --- a/src/crypto/store/indexeddb-crypto-store-backend.js +++ b/src/crypto/store/indexeddb-crypto-store-backend.js @@ -1,4 +1,4 @@ -import q from 'q'; +import Promise from 'bluebird'; import utils from '../../utils'; export const VERSION = 1; diff --git a/src/crypto/store/indexeddb-crypto-store.js b/src/crypto/store/indexeddb-crypto-store.js index 1682c263d..79aa3ad7c 100644 --- a/src/crypto/store/indexeddb-crypto-store.js +++ b/src/crypto/store/indexeddb-crypto-store.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import q from 'q'; +import Promise from 'bluebird'; import MemoryCryptoStore from './memory-crypto-store'; import * as IndexedDBCryptoStoreBackend from './indexeddb-crypto-store-backend'; diff --git a/src/crypto/store/memory-crypto-store.js b/src/crypto/store/memory-crypto-store.js index 3f8e32d7d..f0fe8195f 100644 --- a/src/crypto/store/memory-crypto-store.js +++ b/src/crypto/store/memory-crypto-store.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import q from 'q'; +import Promise from 'bluebird'; import utils from '../../utils'; diff --git a/src/http-api.js b/src/http-api.js index daf7113c5..84d1cbace 100644 --- a/src/http-api.js +++ b/src/http-api.js @@ -18,7 +18,7 @@ limitations under the License. * This is an internal module. See {@link MatrixHttpApi} for the public class. * @module http-api */ -const q = require("q"); +import Promise from 'bluebird'; const parseContentType = require('content-type').parse; const utils = require("./utils"); diff --git a/src/interactive-auth.js b/src/interactive-auth.js index 6ea98afdc..1fc582b61 100644 --- a/src/interactive-auth.js +++ b/src/interactive-auth.js @@ -17,7 +17,7 @@ limitations under the License. "use strict"; /** @module interactive-auth */ -const q = require("q"); +import Promise from 'bluebird'; const url = require("url"); const utils = require("./utils"); diff --git a/src/scheduler.js b/src/scheduler.js index aa72e4967..9740a276c 100644 --- a/src/scheduler.js +++ b/src/scheduler.js @@ -20,7 +20,7 @@ limitations under the License. * @module scheduler */ const utils = require("./utils"); -const q = require("q"); +import Promise from 'bluebird'; const DEBUG = false; // set true to enable console logging. diff --git a/src/store/indexeddb-local-backend.js b/src/store/indexeddb-local-backend.js index 5ee7cabb2..60c753315 100644 --- a/src/store/indexeddb-local-backend.js +++ b/src/store/indexeddb-local-backend.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import q from "q"; +import Promise from 'bluebird'; import SyncAccumulator from "../sync-accumulator"; import utils from "../utils"; diff --git a/src/store/indexeddb-remote-backend.js b/src/store/indexeddb-remote-backend.js index b6adee40e..46a3ff66b 100644 --- a/src/store/indexeddb-remote-backend.js +++ b/src/store/indexeddb-remote-backend.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import q from "q"; +import Promise from 'bluebird'; /** * An IndexedDB store backend where the actual backend sits in a web diff --git a/src/store/indexeddb-store-worker.js b/src/store/indexeddb-store-worker.js index 3212c3bfc..9ca7a7405 100644 --- a/src/store/indexeddb-store-worker.js +++ b/src/store/indexeddb-store-worker.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import q from "q"; +import Promise from 'bluebird'; import LocalIndexedDBStoreBackend from "./indexeddb-local-backend.js"; /** diff --git a/src/store/indexeddb.js b/src/store/indexeddb.js index d1387eb50..cd33537ac 100644 --- a/src/store/indexeddb.js +++ b/src/store/indexeddb.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import q from "q"; +import Promise from 'bluebird'; import {MatrixInMemoryStore} from "./memory"; import utils from "../utils"; import LocalIndexedDBStoreBackend from "./indexeddb-local-backend.js"; diff --git a/src/store/memory.js b/src/store/memory.js index ce9c3c40f..7ae5153c7 100644 --- a/src/store/memory.js +++ b/src/store/memory.js @@ -21,7 +21,7 @@ limitations under the License. */ const utils = require("../utils"); const User = require("../models/user"); - const q = require("q"); +import Promise from 'bluebird'; /** * Construct a new in-memory data store for the Matrix Client. diff --git a/src/store/stub.js b/src/store/stub.js index f18b5101e..22a2cb230 100644 --- a/src/store/stub.js +++ b/src/store/stub.js @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. */ "use strict"; -import q from "q"; +import Promise from 'bluebird'; /** * This is an internal module. * @module store/stub diff --git a/src/sync.js b/src/sync.js index cec791496..a75285378 100644 --- a/src/sync.js +++ b/src/sync.js @@ -24,7 +24,7 @@ limitations under the License. * an alternative syncing API, we may want to have a proper syncing interface * for HTTP and WS at some point. */ -const q = require("q"); +import Promise from 'bluebird'; const User = require("./models/user"); const Room = require("./models/room"); const utils = require("./utils"); diff --git a/src/timeline-window.js b/src/timeline-window.js index b68190cea..8b456acd0 100644 --- a/src/timeline-window.js +++ b/src/timeline-window.js @@ -17,7 +17,7 @@ limitations under the License. /** @module timeline-window */ -const q = require("q"); +import Promise from 'bluebird'; const EventTimeline = require("./models/event-timeline"); /**