MCPcopy Create free account
hub / github.com/Effect-TS/effect / mergeUint8Arrays

Function mergeUint8Arrays

packages/rpc/src/RpcServer.ts:1090–1101  ·  view source on GitHub ↗
(arrays: Chunk.Chunk<Uint8Array>)

Source from the content-addressed store, hash-verified

1088})
1089
1090const mergeUint8Arrays = (arrays: Chunk.Chunk<Uint8Array>) => {
1091 if (arrays.length === 0) return new Uint8Array(0)
1092 if (arrays.length === 1) return Chunk.unsafeHead(arrays)
1093 const length = Chunk.reduce(arrays, 0, (acc, a) => acc + a.length)
1094 const result = new Uint8Array(length)
1095 let offset = 0
1096 for (const array of arrays) {
1097 result.set(array, offset)
1098 offset += array.length
1099 }
1100 return result
1101}
1102
1103/**
1104 * @since 1.0.0

Callers 1

RpcServer.tsFile · 0.85

Calls 1

setMethod · 0.65

Tested by

no test coverage detected