|
1 | 1 | 'use strict'
|
2 | 2 |
|
3 |
| -const assert = require('assert') |
4 | 3 | const errcode = require('err-code')
|
5 | 4 |
|
6 | 5 | const TimeCache = require('time-cache')
|
@@ -261,7 +260,9 @@ class BasicPubSub extends Pubsub {
|
261 | 260 | * @returns {void}
|
262 | 261 | */
|
263 | 262 | subscribe (topics) {
|
264 |
| - assert(this.started, 'Pubsub has not started') |
| 263 | + if (!this.started) { |
| 264 | + throw new Error('Pubsub has not started') |
| 265 | + } |
265 | 266 |
|
266 | 267 | topics = utils.ensureArray(topics)
|
267 | 268 |
|
@@ -305,7 +306,9 @@ class BasicPubSub extends Pubsub {
|
305 | 306 | * @returns {void}
|
306 | 307 | */
|
307 | 308 | unsubscribe (topics) {
|
308 |
| - assert(this.started, 'Pubsub has not started') |
| 309 | + if (!this.started) { |
| 310 | + throw new Error('Pubsub has not started') |
| 311 | + } |
309 | 312 |
|
310 | 313 | topics = utils.ensureArray(topics)
|
311 | 314 |
|
@@ -350,7 +353,9 @@ class BasicPubSub extends Pubsub {
|
350 | 353 | * @returns {void}
|
351 | 354 | */
|
352 | 355 | async publish (topics, messages) {
|
353 |
| - assert(this.started, 'Pubsub has not started') |
| 356 | + if (!this.started) { |
| 357 | + throw new Error('Pubsub has not started') |
| 358 | + } |
354 | 359 |
|
355 | 360 | this.log('publish', topics, messages)
|
356 | 361 |
|
@@ -387,7 +392,9 @@ class BasicPubSub extends Pubsub {
|
387 | 392 | * @returns {Array<String>}
|
388 | 393 | */
|
389 | 394 | getTopics () {
|
390 |
| - assert(this.started, 'Pubsub is not started') |
| 395 | + if (!this.started) { |
| 396 | + throw new Error('Pubsub is not started') |
| 397 | + } |
391 | 398 |
|
392 | 399 | return Array.from(this.subscriptions)
|
393 | 400 | }
|
|
0 commit comments