node-split
Split buffer in Node.js based on gnu split(1).
Installation
$ npm install node-split
API
split(buffer, options, callback)
Asynchronous split. Passes either an array of splitted buffers or error to callback.
splitSync(buffer, options)
Synchronous split. Returns an array of splitted buffers.
Options
-
lines
- Number of lines to put per output files. -
bytes
- Number of bytes to put per output files. -
line_bytes
- Number of bytes to put at most per output files.bytes
andline_bytes
format is integer and optional unit.Units are K, M (powers of 1024) or KB, MB (powers of 1000).
-
prefix
- Prefix of output file names. -
suffix_length
- Length of file name suffixes. -
additional_suffix
- Additional suffix of file names. -
numeric_suffixes
- Start number of numeric suffixes.If you define
numeric_suffixes
, use numeric suffixes instead of alphabetic.
Example
var split = split;var fs = ; fs;
If you define options.prefix
, split
write buffer to files.
var split = split;var fs = ; fs;
splitSync
split buffer synchronously.
var split = splitSync;var fs = ; var data = fs;var splitted = ;