MCPcopy Create free account
hub / github.com/PrismarineJS/node-minecraft-protocol / concat

Function concat

src/transforms/binaryStream.js:5–21  ·  view source on GitHub ↗
(...args)

Source from the content-addressed store, hash-verified

3Object.assign(types, require('../datatypes/minecraft'))
4
5function concat (...args) {
6 let allocLen = 0
7 for (let i = 0; i < args.length; i += 2) {
8 const type = args[i]
9 const value = args[i + 1]
10 const [,, s] = types[type]
11 allocLen += typeof s === 'number' ? s : s(value, {})
12 }
13 const buffer = Buffer.alloc(allocLen)
14 let offset = 0
15 for (let i = 0; i < args.length; i += 2) {
16 const type = args[i]
17 const value = args[i + 1]
18 offset = types[type][1](value, buffer, offset, {})
19 }
20 return buffer
21}
22
23// concat('i32', 22, 'i64', 2n) => <Buffer 00 00 00 16 00 00 00 00 00 00 00 02>
24module.exports = { concat }

Callers 8

updateAndValidateSessionFunction · 0.85
updateAndValidateChatFunction · 0.85
chat.jsFile · 0.85
validateSessionFunction · 0.85
chat.jsFile · 0.85
onLoginFunction · 0.85
onEncryptionKeyResponseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected