remove random chunks of a file given an offset and length
npm install random-access-remove
If you need to remove certain chunks of a file without wanting to do a full copy, this module is for you!
It is easy to use
var randomAccessFile = ;var rar = ;//remove a single piecerar;// or remove in bulkvar file = 'test2.txt';var kb = 1024;var size = fssize;// must be in ascending order by offset values//[ [offset, length], ...]var exclude =0 kb2 * kb + 1 kb4 * kb + 1 kbsize - kb kb;rar;
The format of this module is a copy of the awesome module random-access-file by mafintosh. This module is not affiliated with that module and was written to follow the format outlined in random-access because it makes sense.
Under the hood, this module does the following:
- creates a readstream of the file arg
- creates a tmp output file (file + '.tmp')
- intercepts the piped data and excludes the data within the range/ranges passed to it
- deletes the original file arg
- renames the .tmp file to the original file name