npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bun-split-file

v1.2.2

Published

Split and merge files with Bun

Downloads

36

Readme

bun-split-file

File splitter and merger for Bun
A faster way to split files into parts and safely merge them back with Bun — with optional checksum verification and flexible part-size logic.


Installation

bun add bun-split-file

Requires Bun (https://bun.sh)


Performance compared to existing package: split-file

Tested On
runtime: Bun 1.2.8
Iterations: 10
test-file's size: 100 MB
disk: SSD 

Average bun‑split‑file (split + merge): 460.94 ms
Average split‑file (split + merge): 914.72 ms

Split a File

Split files in multiple ways to match your needs

import { splitFile } from 'bun-split-file';

// Split by fixed part size (10MB each)
await splitFile('./input/video.mp4', './chunks', {
  splitBy: 'size',
  partSize: 10 * 1024 * 1024, // 10MB per part
  createChecksum: 'sha256',
  extraBytesHandling: 'distribute', // distribute extra bytes across parts
});

// Split into specific number of parts
await splitFile('./input/large-dataset.csv', './parts', {
  splitBy: 'numberOfParts',
  numberOfParts: 5,
  createChecksum: 'sha256',
  deleteFileAfterSplit: true, // remove original after splitting
});

// Distribute extra bytes to an additional file
await splitFile('./input/large-dataset.csv', './parts', {
  splitBy: 'numberOfParts',
  numberOfParts: 5,
  extraBytesHandling: 'createNewFile',
});

Merge Files

import { mergeFiles } from 'bun-split-file';

await mergeFiles(
  [
    './chunks/video.mp4.001',
    './chunks/video.mp4.002',
    './chunks/video.mp4.003',
  ],
  './output/video-restored.mp4',
  {
    checksumPath: './chunks/video.mp4.checksum.sha256',
    deletePartsAfterMerge: true,
  }
);

API Reference

splitFile(inputFilePath, outputPath, options)

| Option | Type | Description | | ---------------------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | | splitBy | 'numberOfParts' or 'size' | How to split the file | | numberOfParts | number | Required if splitBy = 'numberOfParts' | | partSize | number | Required if splitBy = 'size' | | createChecksum | SupportedCryptoAlgorithms | Optional hash (e.g., 'sha256') - Supported algorithms | | extraBytesHandling | 'distribute' or 'createNewFile' | Optional. distribute: Distributes extra bytes across parts createNewFile: Creates an additional file for remaining bytes. Default distribute | | deleteFileAfterSplit | boolean | Optional. Delete original file after split, default false |

mergeFiles(inputFilePaths, outputFilePath, options?)

| Option | Type | Description | | ----------------------- | --------- | -------------------------------------------- | | checksumPath | string | Path to file-name.HashAlg file to validate | | deletePartsAfterMerge | boolean | Remove parts after merge |


Output Examples

Splitting Files

With extraBytesHandling: 'distribute'

When splitting a 25MB file into 3 parts with the distribute option:

await splitFile('./input/data.bin', './chunks', {
  splitBy: 'numberOfParts',
  numberOfParts: 3,
  createChecksum: 'sha256',
  extraBytesHandling: 'distribute', // distribute extra bytes across parts
});
Input: data.bin (25MB)
Output directory: ./chunks/

Generated files:
- data.bin.001 (8.34MB)  // Gets extra bytes
- data.bin.002 (8.33MB)  // Gets extra bytes
- data.bin.003 (8.33MB)  // Gets extra bytes
- data.bin.checksum.sha256

With extraBytesHandling: 'createNewFile'

When splitting a 25MB file into 3 parts with the createNewFile option:

await splitFile('./input/data.bin', './chunks', {
  splitBy: 'numberOfParts',
  numberOfParts: 3,
  createChecksum: 'sha256',
  extraBytesHandling: 'createNewFile', // put extra bytes in a new file
});
Input: data.bin (25MB)
Output directory: ./chunks/

Generated files:
- data.bin.001 (8MB)     // Equal division
- data.bin.002 (8MB)     // Equal division
- data.bin.003 (8MB)     // Equal division
- data.bin.004 (1MB)     // Contains remainder bytes
- data.bin.checksum.sha256

Merging Files

When merging files, the library combines all parts and optionally verifies the checksum

Input parts:
- ./chunks/video.mp4.001
- ./chunks/video.mp4.002
- ./chunks/video.mp4.003
- ./chunks/video.mp4.004
Cheksum:
- ./chunks/video.mp4.checksum.sha256

Output: ./output/video-restored.mp4 (25MB)

Author

github.com/apirJS


License

MIT © 2025 apirJS