Show HN: Ultra-lightweight chunker library with emoji support

https://news.ycombinator.com/rss Hits: 2
Summary

Ultra-lightweight chunker for everything โ€” arrays, strings, sets, maps, async iterables and more. ๐Ÿ“ฆ Installation npm install chonkify โœจ Features Works with everything: Array, String, Buffer, Set, Map, Array-like, TypedArray Array, String, Buffer, Set, Map, Array-like, TypedArray Supports AsyncIterable ( for await ) ( ) Correctly handles Unicode emoji and complex symbols ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ ๐Ÿณ๏ธโ€๐ŸŒˆ ๐ŸŽ‰ and complex symbols ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ ๐Ÿณ๏ธโ€๐ŸŒˆ ๐ŸŽ‰ Minimal size: core just 870 bytes, entire package ~5.5 kB core just 870 bytes, entire package ~5.5 kB Zero dependencies ESM-first, TypeScript-ready ๐Ÿงช Usage import { chonk , chonkAsync } from 'chonkify' ; // Basic examples chonk ( [ 1 , 2 , 3 , 4 ] , 2 ) ; // [[1, 2], [3, 4]] chonk ( 'abcdef' , 2 ) ; // ['ab', 'cd', 'ef'] // Unicode emoji support chonk ( '๐Ÿ‘๐Ÿ‘ŒโœŒ๏ธ๐Ÿ˜€' , 2 ) ; // ['๐Ÿ‘๐Ÿ‘Œ', 'โœŒ๏ธ๐Ÿ˜€'] chonk ( '๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ๐Ÿณ๏ธโ€๐ŸŒˆ' , 1 ) ; // ['๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ', '๐Ÿณ๏ธโ€๐ŸŒˆ'] // Async usage: for await ( const group of chonkAsync ( fetchLines ( ) , 100 ) ) { console . log ( group ) ; } ๐Ÿ” API Splits an iterable into groups of the specified size. chonk ( [ 1 , 2 , 3 , 4 , 5 ] , 2 ) ; // [[1, 2], [3, 4], [5]] Asynchronously splits an iterable into groups of the specified size. // Process large datasets in batches for await ( const batch of chonkAsync ( dataStream , 100 ) ) { await processBatch ( batch ) ; } ๐Ÿค” FAQ Can I use chonkify with Node.js? Yes, chonkify works both in browsers and Node.js environments. Does it support nested data structures? Yes, chonkify can handle nested data structures as it groups elements without transforming them. ๐Ÿ“„ License MIT

First seen: 2025-06-03 17:42

Last seen: 2025-06-03 18:42