buffer-split-utils
v0.2.0
Published
Utilities for buffers
Downloads
21
Maintainers
Readme
buffer-split-utils
Utilities for splitting buffers, especially useful for Transform
objects in stream pipes.
Usage:
split(buffer, splitBuffer)
Split buffer
at every occurrence of splitBuffer
; returns an array of buffers.
splitOnce(buffer, splitBuffer)
Split buffer
at the first occurrence of splitBuffer
; returns an array of two buffers, Buffer
objects before and after the first occurrence of splitBuffer
respectively.
splitN(buffer, splitBuffer, n)
Split buffer
at the first n
occurrences of splitBuffer
; returns an array of n
+1 buffers; the first n
items are the split Buffer
objects, and the last Buffer
is the remainder of buffer
.
splitAtNth(buffer, splitBuffer, nth)
Split buffer
at the nth occurrence of splitBuffer
; returns an array of buffers.
splitOnceAtNth(buffer, splitBuffer, nth)
Split buffer
once at the nth
occurrence of splitBuffer
; returns an array of two buffers, Buffer
objects before and after the first occurrence of splitBuffer
respectively.
splitNAtNth(buffer, splitBuffer, n, nth)
Split buffer
n
times at the nth
occurrence of splitBuffer
; returns an array of n
+1 buffers, Buffer
objects before and after the first occurrence of splitBuffer
respectively.
nthIndexOf(buffer, splitBuffer, nth)
Returns the position of the nth
occurrence of splitBuffer
within buffer
.