mirror of
https://github.com/jwetzell/psn-js.git
synced 2026-08-20 14:39:11 +00:00
replace NodeJS buffer with Uint8Array
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
import chunk from '../chunk';
|
||||
|
||||
export default (trackerChunks: Buffer[]) => chunk(0x0001, Buffer.concat(trackerChunks), true);
|
||||
export default (trackerChunks: Uint8Array[]) => {
|
||||
let trackerChunksTotalLength = 0;
|
||||
|
||||
trackerChunks.forEach((trackerChunk) => {
|
||||
trackerChunksTotalLength += trackerChunk.length;
|
||||
});
|
||||
|
||||
const trackerChunksBytes = new Uint8Array(trackerChunksTotalLength);
|
||||
|
||||
let offset = 0;
|
||||
|
||||
trackerChunks.forEach((trackerChunk) => {
|
||||
trackerChunksBytes.set(trackerChunk, offset);
|
||||
offset += trackerChunk.length;
|
||||
});
|
||||
|
||||
return chunk(0x0001, trackerChunksBytes, true);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user