1.0.2 • Published 8 years ago

split-by-line v1.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

split-by-line

A NodeJS module that splits a file into parts while preserving lines.

Install with npm install split-by-line

##Example Split by line splits a file into a specified number of files but preserves the lines of the file.

const splitByLine = require('split-by-line');

splitByLine('file.txt', {
	number: 3
}, function(err, files) {
	// files is an array with the resulting filenames
	console.log(files);
	// Prints:
	// ['file.txt.part0', 'file.txt.part1', 'file.txt.part2']
});

Api

splitByLine(inputFile, [opts], callback)

  • the first parameter is the file that gets split
  • the second parameter are optional options
  • the callback will be called with err and files, where files is an array containing the file names of the created files

Currently it is not guaranteed that the lines stay in order

Options

options = {
	number: 2, // The number of files that are created (1000 is maximum)
	keepEmpty: true, // If the number of files is bigger than the number of lines, decide whether to keep the remaining empty files or not
	outputDir: path.dirname(inputFile), // The folder in which the files are stored
	minLines: 1 // The minimum number of lines one file should have.
}
1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago