npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@themartiancompany/split-file

v2.3.5

Published

Splitting and merging files with NodeJS.

Readme

Split File

Split and merge file in multiple parts. Splittable with number of parts or maximum bytes per part.

It works both in Node.js and in web browsers.

Installation

You can install and save an entry to your package.json with the following command:

npm \
  install \
    --save \
    @themartiancompany/split-file

Usage

All methods return a Promise (bluebird) which results in some respose if some.

Splitting file with number of parts

_split_file(
  _input_file,
  _output_dir?) => Promise<string[]>

Consumes:

  • _input_file: Path to the file to split.
  • _output_dir: Folder for output, defaults to . (current folder)

Produces:

  • Promise<string[]>: Promise with results in an array of part names (full paths) of the splitted files.

Example

const
  _split_file_module =
    require(
      'split-file');
_split_file =
  _split_file_module._split_file;
const
  _input_file =
    __dirname +
    '/testfile.bin';
const
  _parts_amount =
    3;
const
  _error_callback =
    function (
      _error) {
      const
        _log =
          console.log;
      _log(
        'Error: ',
        _error);
    };
_split_file(
  _input_file,
  _parts_amount)
  .then(
    (_output_files) => {
      console.log(
        _output_files);
    })
  .catch(
    _error_callback);

Splitting file with maximum bytes per part

_split_file_by_size(
  _input_file,
  _size_max,
  _output_dir?) => Promise<string[]>

Consumes:

  • _input_file: Path to the file to split.
  • _size_max: Max size of the splitted parts. (bytes)
  • _output_dir: Folder for output, defaults to . (current folder)

Produces:

  • Promise<string[]>: Promise with results in an array of part names (full paths) of the splitted files.
Example
const
  _split_file_module =
    require(
      'split-file');
_split_file_by_size =
  _split_file_module._split_file_by_size;
const
  _input_file =
    __dirname +
    '/testfile.bin';
_size_max =
  457000;
const
  _error_callback =
    function (
      _error) {
      const
        _log =
          console.log;
      _log(
        'Error: ',
        _error);
    };
_split_file_by_size(
  _input_file,
  _size_max)
  .then(
    (_output_files) => {
      console.log(
        _output_files);
    })
  .catch(
    _error_callback);

Merge parts

_merge_files(
  _input_files,
  _output_file) => Promise<>

Consumes:

  • _input_files: Input files, array with full part paths.
  • _output_file: Full path of the output file.

Produces:

  • Promise<>: Promise that results in an empty resolving.
Example
const
  _split_file_module =
    require(
      'split-file');
_merge_files =
  _split_file_module._merge_files;
const
  _input_files = [
    __dirname + '/file_a',
    __dirname + '/file_b'
  ];
const
  _output_file =
    __dirname +
    '/testfile-output.bin';
const
  _error_callback =
    function (
      _error) {
      const
        _log =
          console.log;
      _log(
        'Error: ',
        _error);
    };
_merge_files(
  _input_files,
  _output_file)
  .then(
    () => {
      console.log(
        'Done!');
    })
  .catch(
    _error_callback);

Command-line program

Installation

To use the module from the command line you can install either use npm and install this package in your global context

npm \
  -g \
  install \
    "split-file"

or just use GNU make

make \
  install

Note: You may need admin rights (sudo, su -c or on Windows Run as administrator).

Usage

The CLI tool works like you use it in your own package.

The manual can be accessed with man split-file.

split-file \
  -h

Usage:

  split-file
    <option>
    [arguments]

  options:

     -s                          Split the input file in
       <input>                   the given number of parts.
       <num_parts>

     -x
       <input>
       <max_size>                Split the input file into
                                 multiple parts with maximum
                                 file size of max_size bytes.

     -m                          Merge the given parts into
       <output>                  the output file.
       <part>
       <part> ...
        
  examples:
  
     split-file \
       -s \
       "input.bin" \
       5
  
     split-file \
       -x \
       "input.bin" \
       457000
  
     split-file \
       -m \
       "output.bin" \
       "part1" "part2" ...

License

Work authored by Tom Valk is released under the terms of the MIT license; work authored by Pellegrino Prevete is released under the terms of the GNU Affero General Public License version 3.