node-delete-partial
v2.0.0
Published
An easy and simple to use Node module to efficiently remove the first X number of lines from an inputstream. It uses streams, which means it doesn't need to load whole files in memory, so it is way more efficient and fast, as well can work on very large f
Downloads
9
Maintainers
Readme
An easy and simple to use Node module to efficiently remove the first X number of lines from an inputstream. It uses streams, which means it doesn't need to load whole files in memory, so it is way more efficient and fast, as well can work on very large files without filling memory on the hardware.
Learn more about the installation and how to use this package in the updated documentation page.
:open_file_folder: Index
1. Install
2. Large File Usage Example
3. Small File Usage Example
4. API
5. Author
6. Contribute
7. License
:gem: Install
Type in the following to the command line to install the dependency.
$ npm install --save node-delete-partial
or
$ yarn add node-delete-partial
:tada: Large File Usage Example
var { deletePartialStream } = require('node-delete-partial');
var fs = require('fs');
var input = fs.createReadStream(process.cwd() + '/input.txt');
var output = fs.createWriteStream(process.cwd() + '/output.txt');
input
// delete 5 lines from beginning of file
.pipe(deletePartialStream(5))
.pipe(output);
:tada: Small File Usage Example
var { deletePartials } = require('node-delete-partial');
var filePath = process.cwd() + '/file.txt';
deletePartials(filePath, { lines: 5 }, function (err) {
if (err) {
console.log(err);
}
console.log('Completed');
});
:nut_and_bolt: API
:large_blue_diamond: deletePartialStream(lines)
Parameters:
Name | Type | Required | Description
------ | ------ | ------ | ------
lines | number | NO | Delete the number of lines from the beginning of the file. Default is 1
.
:large_blue_diamond: deletePartials(path[, options], callback)
Parameters:
Name | Type | Required | Description
------ | ------ | ------ | ------
path | string | YES | File to delete from and update.
options | Object | NO | See below.
callback | Function | NO | The callback gets one argument (err)
.
Valid options keys are:
- "lines" (number) - Delete the number of lines from the beginning of the file. Default is
1
.
:santa: Author
Free and made possible along with costly maintenance and updates by Lue Hang (the author).
:clap: Contribute
Pull requests are welcomed.
:tophat: Contributors
Contributors will be posted here.
:baby: Beginners
Not sure where to start, or a beginner? Take a look at the issues page.
:page_facing_up: License
MIT © Lue Hang, as found in the LICENSE file.