Skip to content

Commit

Permalink
chore: review addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Jul 11, 2019
1 parent 4dd2e46 commit 913c809
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ module.exports = (node) => {
return nextTick(callback, errCode(new Error(messages.NOT_STARTED_YET), codes.PUBSUB_NOT_STARTED))
}

if (!Buffer.isBuffer(data) && typeof data !== 'string') {
return nextTick(callback, errCode(new Error('data must be a Buffer or a String'), 'ERR_DATA_IS_NOT_VALID'))
}

if (!Buffer.isBuffer(data)) {
try {
data = Buffer.from(data)
} catch (err) {
return nextTick(callback, errCode(new Error('data must be convertible to a Buffer'), 'ERR_DATA_IS_NOT_VALID'))
}

pubsub.publish(topic, data, callback)
Expand Down

0 comments on commit 913c809

Please sign in to comment.