1.0.2 • Published 5 months ago

equal-chunks v1.0.2

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

šŸ“¦ equal-chunks

A simple utility to split payloads into equal-sized chunks.

Installation

This is a Node.js package available through the npm registry.

npm install equal-chunks

or via yarn:

yarn add equal-chunks

šŸ“Œ Usage

1ļøāƒ£ Import the Function

import { createChunksBySize } from "equal-chunks";

2ļøāƒ£ Chunk a JSON Object

const data = { message: "Hello, this is a large payload that needs chunking!" };
const chunks = createChunksBySize(data, 10);
console.log(chunks);

šŸ“Œ Output:

[
  '{"message',
  '":"Hello, ',
  "this is a ",
  "large payl",
  "oad that n",
  "eeds chunk",
  'ing!"}',
];

⚔ API Reference

createChunksBySize(payload, maxChunkSize);
ParameterTypeDescription
payloadobject | stringThe data to split into chunks.
maxChunkSizenumberMaximum chunk size in bytes.

šŸ“Œ Returns: An array of chunked strings.

āœ… Why Choose equal-chunks?

āœ”ļø Supports both strings & JSON objects – Works seamlessly with different data types.

āœ”ļø Splits data into evenly sized chunks – Ensures consistency across chunks.

āœ”ļø Lightweight & dependency-free – No external libraries required.

āœ”ļø Compatible with Node.js & Browsers – Use it anywhere with ease.

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago