# @guanghechen/file-split

> File helper

Latest version **2.0.0** (published 2026-02-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @guanghechen/file-split
pnpm add @guanghechen/file-split
yarn add @guanghechen/file-split
bun add @guanghechen/file-split
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2026-02-04 |
| First published | 2023-10-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 37.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | guanghechen |
| Maintainers | lemonclown |
| Keywords | file helper, split file, merge streams |

## Links

- npm: https://www.npmjs.com/package/@guanghechen/file-split
- Repository: https://github.com/guanghechen/sora.git#@guanghechen
- Homepage: https://github.com/guanghechen/sora/tree/@guanghechen/file-split@1.0.4/packages/file-split#readme
- Issues: https://github.com/guanghechen/sora/issues
- npm.io page: https://npm.io/package/@guanghechen/file-split

## Dependencies (3)

- [@guanghechen/stream](https://npm.io/package/@guanghechen/stream.md) ^2.0.0
- [@guanghechen/filepart](https://npm.io/package/@guanghechen/filepart.md) ^2.0.0
- [@guanghechen/invariant](https://npm.io/package/@guanghechen/invariant.md) ^7.0.0

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2026-02-04
- 1.0.4 — 2025-02-26
- 1.0.3 — 2024-10-03
- 1.0.2 — 2024-09-28
- 1.0.1 — 2024-09-25
- 1.0.0 — 2024-09-20
- 1.0.0-alpha.23 — 2024-09-18
- 1.0.0-alpha.22 — 2024-03-10
- 1.0.0-alpha.21 — 2024-03-09
- 1.0.0-alpha.20 — 2024-02-03
- 1.0.0-alpha.19 — 2024-01-15
- 1.0.0-alpha.18 — 2024-01-02
- 1.0.0-alpha.17 — 2023-12-10
- 1.0.0-alpha.16 — 2023-12-07
- 1.0.0-alpha.15 — 2023-12-04
- … 14 more at https://npm.io/package/@guanghechen/file-split/versions

## README

<header>
  <h1 align="center">
    <a href="https://github.com/guanghechen/sora/tree/@guanghechen/file-split@2.0.0/packages/file-split#readme">@guanghechen/file-split</a>
  </h1>
  <div align="center">
    <a href="https://www.npmjs.com/package/@guanghechen/file-split">
      <img
        alt="Npm Version"
        src="https://img.shields.io/npm/v/@guanghechen/file-split.svg"
      />
    </a>
    <a href="https://www.npmjs.com/package/@guanghechen/file-split">
      <img
        alt="Npm Download"
        src="https://img.shields.io/npm/dm/@guanghechen/file-split.svg"
      />
    </a>
    <a href="https://www.npmjs.com/package/@guanghechen/file-split">
      <img
        alt="Npm License"
        src="https://img.shields.io/npm/l/@guanghechen/file-split.svg"
      />
    </a>
    <a href="#install">
      <img
        alt="Module Formats: cjs"
        src="https://img.shields.io/badge/module_formats-cjs-green.svg"
      />
    </a>
    <a href="https://github.com/nodejs/node">
      <img
        alt="Node.js Version"
        src="https://img.shields.io/node/v/@guanghechen/file-split"
      />
    </a>
    <a href="https://github.com/facebook/jest">
      <img
        alt="Tested with Jest"
        src="https://img.shields.io/badge/tested_with-jest-9c465e.svg"
      />
    </a>
    <a href="https://github.com/prettier/prettier">
      <img
        alt="Code Style: prettier"
        src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square"
      />
    </a>
  </div>
</header>
<br/>

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

## Install

- npm

  ```bash
  npm install --save @guanghechen/file-split
  ```

- yarn

  ```bash
  yarn add @guanghechen/file-split
  ```

## Usage

- `FileSplitter` (inspired by [file-split][])

  ```typescript
  import { FileSplitter } from '@guanghechen/file-split'
  import { calcFilePartItemsBySize } from '@guanghechen/filepart'

  async function splitFile(filepath: string): Promise<string[]> {
    const splitter = new FileSplitter()
    const parts = calcFilePartItemsBySize(filepath, 1024 * 1024 * 80) // 80MB per chunk
    const partFilepaths: string[] = await splitter.split(filepath, parts)
    return partFilepaths
  }

  splitFile('big-file.txt')
  ```

### Overview

|       Name       |                  Description                  |
| :--------------: | :-------------------------------------------: |
|  `FileSplitter`  | A utility class for splitting / merging files |

[homepage]:
  https://github.com/guanghechen/sora/tree/@guanghechen/file-split@2.0.0/packages/file-split#readme
[file-split]: https://github.com/tomvlk/node-file-split

---
_Source: https://npm.io/package/@guanghechen/file-split · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
