@guanghechen/file-helper
v1.9.8
Published
File helper
Downloads
5
Maintainers
Readme
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
Name | Description
:----------------------------------:|:----------------------------:
absoluteOfWorkspace
| Calc absolute path of p under the workspace
BigFileHelper
| A utility class for split / merging big files
bigFileHelper
| Default instance of BigFleHelper
calcFilePartItemsBySize
| Generate file part items by part size
calcFilePartItemsByCount
| Generate file part items by total of parts
collectAllFiles
| Collect all files under the given directory
collectAllFilesSync
| Collect all files under the given directory (synchronizing)
consumeStreams
| Consume multiple streams serially
ensureCriticalFilepathExistsSync
| Ensure critical filepath exists
isDirectorySync
| Check whether if the dirpath is a directory path
isFileSync
| Check whether if the filepath is a file path
isNonExistentOrEmpty
| Check whether if the dirPath is a non-existent path or empty folder
mkdirsIfNotExists
| Create a path of directories
relativeOfWorkspace
| Calc relative path to workspace