UNPKG
tcp2
Version:
latest (1.0.0-beta1)
1.0.0-beta1
0.0.3-alpha1
0.0.2-alpha1
0.0.1-alpha1
A Wrapper of Node.JS' net API
github.com/NekoMaru76/tcp2
NekoMaru76/tcp2
tcp2
/
splitBytes.js
9 lines
(7 loc)
•
247 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
module
.
exports
=
function
splitBytes
(
buffer, maxBytes
) {
const
result = [];
for
(
let
i =
0
; i <
Math
.
ceil
(buffer.
byteLength
/maxBytes); i++) { result.
push
(buffer.
slice
(maxBytes*(i+
1
)-maxBytes, maxBytes*(i+
1
))); }
return
result; };