* @param {Array. } parts * @param {Number} totalLength * @returns {Buffer} * @private
(parts, totalLength)
| 2131 | * @private |
| 2132 | */ |
| 2133 | function concatRoutingKey(parts, totalLength) { |
| 2134 | if (totalLength === 0) { |
| 2135 | return null; |
| 2136 | } |
| 2137 | if (parts.length === 1) { |
| 2138 | return parts[0]; |
| 2139 | } |
| 2140 | const routingKey = utils.allocBufferUnsafe(totalLength); |
| 2141 | let offset = 0; |
| 2142 | for (let i = 0; i < parts.length; i++) { |
| 2143 | const item = parts[i]; |
| 2144 | routingKey.writeUInt16BE(item.length, offset); |
| 2145 | offset += 2; |
| 2146 | item.copy(routingKey, offset); |
| 2147 | offset += item.length; |
| 2148 | routingKey[offset] = 0; |
| 2149 | offset++; |
| 2150 | } |
| 2151 | return routingKey; |
| 2152 | } |
| 2153 | |
| 2154 | function invertObject(obj) { |
| 2155 | const rv = {}; |
no outgoing calls
no test coverage detected