1.9.8 • Published 2 years ago

@guanghechen/file-helper v1.9.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years 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-helper
  • yarn

    yarn add @guanghechen/file-helper

Usage

  • BigFileHelper (inspired by split-file)

    import { 
      bigFileHelper, 
      calcFilePartItemsBySize,
    } from '@guanghechen/file-helper'
    
    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
absoluteOfWorkspaceCalc absolute path of p under the workspace
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
collectAllFilesCollect all files under the given directory
collectAllFilesSyncCollect all files under the given directory (synchronizing)
consumeStreamsConsume multiple streams serially
ensureCriticalFilepathExistsSyncEnsure critical filepath exists
isDirectorySyncCheck whether if the dirpath is a directory path
isFileSyncCheck whether if the filepath is a file path
isNonExistentOrEmptyCheck whether if the dirPath is a non-existent path or empty folder
mkdirsIfNotExistsCreate a path of directories
relativeOfWorkspaceCalc relative path to workspace
1.9.8

2 years ago

1.9.7

2 years ago

1.9.6

2 years ago

1.9.5

2 years ago

1.9.0-alpha.0

2 years ago

1.9.1

2 years ago

1.9.0

2 years ago

1.8.6

2 years ago

1.9.4

2 years ago

1.9.3

2 years ago

1.9.2

2 years ago

1.8.5

2 years ago

1.8.4

3 years ago

1.8.3

3 years ago

1.8.2

3 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.1

3 years ago

1.7.0

3 years ago

1.7.0-alpha.3

3 years ago

1.7.0-alpha.2

3 years ago

1.7.0-alpha.1

3 years ago

1.7.0-alpha.0

3 years ago