1.0.2 • Published 9 months ago

arrkit v1.0.2

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

arrkit šŸ“¦

Simple yet powerful array chunking utility - split arrays into chunks with ease.

Features

  • šŸš€ Lightweight & fast
  • šŸ›”ļø TypeScript support
  • šŸ’Ŗ Zero dependencies
  • šŸŽÆ Memory efficient with iterator support
  • ✨ Simple API

Installation

npm install arrkit

## Usage
import arrkit from 'arrkit';

// Basic chunking
const numbers = [1, 2, 3, 4, 5];
arrkit(numbers, 2);
// Output: [[1, 2], [3, 4], [5]]

// Fill incomplete chunks
const data = ['a', 'b', 'c', 'd', 'e'];
arrkit(data, 3, { 
  fillIncomplete: true, 
  fillValue: null 
});
// Output: [['a', 'b', 'c'], ['d', 'e', null]]

// Memory efficient iteration
const bigArray = [1, 2, 3, 4, 5, 6, 7, 8];
const iterator = arrkit(bigArray, 3, { 
  returnIterator: true 
});

for (const chunk of iterator) {
  console.log(chunk);
}

## API

arrkit<T>(array: T[], size: number, options?: ChunkOptions)
Parameters
ParameterTypeDescriptionarrayT[]Array to chunksizenumberSize of each chunkoptionsChunkOptionsOptional configuration
Options
OptionTypeDefaultDescriptionfillIncompletebooleanfalseFill incomplete chunksfillValueanyundefinedValue for fillingreturnIteratorbooleanfalseReturn generator instead of array
Common Use Cases

šŸ”„ Batch processing large datasets
šŸ“± Creating grid layouts
šŸš€ API request batching
šŸ“Š Data visualization

Connect

🐦 Twitter: @azagsam
ā˜• Buy me a coffee buymeacoffee.com/azgsami

License
MIT
1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago