All Projects β†’ tomvlk β†’ node-split-file

tomvlk / node-split-file

Licence: MIT License
🌱 NodeJS Module to split and merge files for several purposes like transporting over unstable networks.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to node-split-file

P State
Inspect the state of a promise
Stars: ✭ 108 (+227.27%)
Mutual labels:  promise, npm-package
Byte Size
Isomorphic function to convert a bytes value (e.g. 3456) to a human-readable string ('3.5 kB')
Stars: ✭ 33 (+0%)
Mutual labels:  npm-package, bytes
Emittery
Simple and modern async event emitter
Stars: ✭ 1,146 (+3372.73%)
Mutual labels:  promise, npm-package
P Queue
Promise queue with concurrency control
Stars: ✭ 1,863 (+5545.45%)
Mutual labels:  promise, npm-package
Github Files Fetcher
Download a specific folder or file from a GitHub repo through command line
Stars: ✭ 73 (+121.21%)
Mutual labels:  files, npm-package
split-on-first
Split a string on the first occurrence of a given separator
Stars: ✭ 68 (+106.06%)
Mutual labels:  split, npm-package
retryx
Promise-based retry workflow library.
Stars: ✭ 21 (-36.36%)
Mutual labels:  promise, npm-package
replace-in-files
Replace text in one or more files or globs.
Stars: ✭ 21 (-36.36%)
Mutual labels:  files, promise
Promises
It's just another Promise library...
Stars: ✭ 43 (+30.3%)
Mutual labels:  promise
Zeus
πŸ”­ A modern cross platform `ls` with powerful searching and querying capabilities to scale your productivity to the moon πŸš€ (and yeah it has file explorer like capabilities too 🀫)
Stars: ✭ 75 (+127.27%)
Mutual labels:  files
ttv
A command line tool for splitting files into test, train, and validation sets.
Stars: ✭ 38 (+15.15%)
Mutual labels:  split
wakatime-client
πŸ–₯ JavaScript Client for https://wakatime.com/developers
Stars: ✭ 29 (-12.12%)
Mutual labels:  npm-package
tish
A replacement of shell script with TypeScript, for those who love TypeScript and tired of writing shell script, aiming to emulate shell script in TypeScript.
Stars: ✭ 119 (+260.61%)
Mutual labels:  promise
bs-promise-monad
Monadic syntax to work with promise in ReasonML
Stars: ✭ 38 (+15.15%)
Mutual labels:  promise
run exclusive
βš‘πŸ”’ Wait queue for function execution πŸ”’ ⚑
Stars: ✭ 22 (-33.33%)
Mutual labels:  promise
executive
πŸ•΄Elegant command execution for Node.
Stars: ✭ 37 (+12.12%)
Mutual labels:  promise
js-types
List of JavaScript types
Stars: ✭ 74 (+124.24%)
Mutual labels:  npm-package
github-content
Easily download files from github raw user content.
Stars: ✭ 21 (-36.36%)
Mutual labels:  files
MeeInk
Material Design click effect
Stars: ✭ 33 (+0%)
Mutual labels:  npm-package
guess-filename.py
Derive a file name according to old file name cues and/or PDF file content
Stars: ✭ 27 (-18.18%)
Mutual labels:  files

Split File

Build Status

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

Programmatically usage

This section contains information on how to use the split-file module in your code.

Installation

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

npm i --save split-file

Usage

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

Splitting file with number of parts

splitFile(file, dest?) => Promise<string[]>

Consumes:

  • file: Path to the file to split.
  • dest: 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 splitFile = require('split-file');

splitFile.splitFile(__dirname + '/testfile.bin', 3)
  .then((names) => {
    console.log(names);
  })
  .catch((err) => {
    console.log('Error: ', err);
  });

Splitting file with maximum bytes per part

splitFileBySize(file, maxSize, dest?) => Promise<string[]>

Consumes:

  • file: Path to the file to split.
  • maxSize: Max size of the splitted parts. (bytes)
  • dest: 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 splitFile = require('split-file');

splitFile.splitFileBySize(__dirname + '/testfile.bin', 457000)
  .then((names) => {
    console.log(names);
  })
  .catch((err) => {
    console.log('Error: ', err);
  });

Merge parts

mergeFiles(names, outputFile) => Promise<>

Consumes:

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

Produces:

  • Promise<>: Promise that results in an empty resolving.

Example:

const splitFile = require('split-file');

splitFile.mergeFiles(names, __dirname + '/testfile-output.bin')
  .then(() => {
    console.log('Done!');
  })
  .catch((err) => {
    console.log('Error: ', err);
  });

CLI Tool

Installation

To use the module from the commandline you can install this package in your global context:

npm i -g split-file

Some situations you need admin rights (sudo or windows run as admin)

Usage

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

Usage: split-file -s input.bin 5
       split-file -x input.bin 457000
       split-file -m output.bin part1 part2 ...

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

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

 -m <output> <part> <part> ...
    Merge the given parts into the output file.

License

License is MIT, see LICENSE

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].