1.0.0-alpha.22 • Published 2 months ago

@guanghechen/file-split v1.0.0-alpha.22

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

A collection of utility functions for handling files, such as split big file or merge multiple small files.

Install

  • npm

    npm install --save @guanghechen/file-split
  • yarn

    yarn add @guanghechen/file-split

Usage

  • BigFileHelper (inspired by file-split)

    import { bigFileHelper, calcFilePartItemsBySize } from '@guanghechen/file-split'
    
    async function splitFile(filepath: string): Promise<string[]> {
      const parts = calcFilePartItemsBySize(filepath, 1024 * 1024 * 80) // 80MB per chunk
      const partFilepaths: string[] = await bigFileHelper.split(filepath, parts)
      return partFilepaths
    }
    
    splitFile('big-file.txt')

Overview

NameDescription
BigFileHelperA utility class for split / merging big files
bigFileHelperDefault instance of BigFleHelper
calcFilePartItemsBySizeGenerate file part items by part size
calcFilePartItemsByCountGenerate file part items by total of parts
calcFilePartNamesGenerate file part names (suffix)