buffer-slice

slice a buffer into an array of sub buffers

buffer-slice

Slice a buffer into an array of sub-buffers of a specified size.

Very handy for UDP packets.

npm install buffer-slice

var bufferSlice = require('buffer-slice');
 
//slice a length 5 buffer into max length 2 
var buffers = bufferSlice(Buffer([1, 2, 3, 4, 5]), 2);
console.log(buffers);
//<Buffer 1 2> 
//<Buffer 3 4> 
//<Buffer 5> 

MIT