lib/message-utils.js
function (value, encoding) {
    encoding = (typeof encoding === 'undefined') ? 'utf8' : encoding
    var returnValue = value
    if (!Buffer.isBuffer(returnValue)) {
      if (value === null) {
        returnValue = ''
      } else if (typeof value === 'object') {
        returnValue = module.exports.objectToJson(value)
      } else if (typeof value !== 'string') {
        returnValue = '' + value
      }
      returnValue = Buffer.from(returnValue, encoding)
    }
    return returnValue
  }
function (value, encoding) {
    encoding = (typeof encoding === 'undefined') ? 'utf8' : encoding
    var returnValue = value
    if (!Buffer.isBuffer(returnValue)) {
      if (value === null) {
        returnValue = ''
      } else if (typeof value === 'object') {
        returnValue = module.exports.objectToJson(value)
      } else if (typeof value !== 'string') {
        returnValue = '' + value
      }
      returnValue = Buffer.from(returnValue, encoding)
    }
    return returnValue
  }
function ( value , encoding ) { encoding = ( typeof encoding === 'undefined' ) ? 'utf8' : encoding var returnValue = value if ( ! Buffer . isBuffer ( returnValue ) ) { if ( value === null ) { returnValue = '' } else if ( typeof value === 'object' ) { returnValue = module . exports . objectToJson ( value ) } else if ( typeof value !== 'string' ) { returnValue = '' + value } returnValue = Buffer . from ( returnValue , encoding ) } return returnValue }
Encodes the specified value and returns it.
@param value - The value.
@param {String} [encoding=utf8] - The encoding of the payload.
@returns {Buffer} The encoded value.
Encodes the specified value and returns it .