{"_id":"@sindresorhus/chunkify","_rev":"5-bafe678ff1526ce8134e616300796eee","name":"@sindresorhus/chunkify","dist-tags":{"latest":"2.0.0"},"versions":{"0.1.0":{"name":"@sindresorhus/chunkify","version":"0.1.0","description":"Split an iterable into evenly sized chunks","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/chunkify.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["chunkify","chunk","chunks","chunked","chunking","array","iterable","iterator","generator","set","map","parts","split","size"],"devDependencies":{"ava":"^3.15.0","tsd":"^0.14.0","xo":"^0.37.1"},"gitHead":"ecdb81b6ab80e2ab37c03d594aa9fef40ecf0bf2","bugs":{"url":"https://github.com/sindresorhus/chunkify/issues"},"homepage":"https://github.com/sindresorhus/chunkify#readme","_id":"@sindresorhus/chunkify@0.1.0","_nodeVersion":"14.15.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-00aDd8DmRw8ZIDYv5ISUPX3pt909EcfcMaNunr6SP5vFttITWqta7Nr/GWlFtB+gaA6nnGFFz4CO0+wD7UOhKA==","shasum":"d4991d73b358744a81325ef69607be8aaabca077","tarball":"https://registry.npmjs.org/@sindresorhus/chunkify/-/chunkify-0.1.0.tgz","fileCount":5,"unpackedSize":3767,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgEUm8CRA9TVsSAnZWagAA1hQP/1LDbShms8wSc/jJjVf5\nrUZukHA8E5waaZrSGzupQ8XynFxfoiuSOvHvvKkMQksPcg9idEOf7V6gfTlO\nbcU4tKxvG4KZqFQZfB/4Yu++Dfj5tWFqJM9Ddi33QrlfkybCSW7B2figggDy\nLmzzlSIlOqsilN7SHjKn7lAW8Vt1SqEwVDcTHoW5CrWBRqcUSfI54UvLcS+H\nbwozfIENEqVS+Me92MTjM1jjd4FoN0mjqXFw0Uh3FcjOJCYAb23QuHRRSowD\nb15SqsIvEst5RXYsmcuHPwr8b/Th/tOp2CdmI3Yz5reWS4Bx/jvvwOX4uAah\njSvcwFYQTIcPSEFTiwVfMpQVjW8P3UvB2pD8Jox07Xj8d+9+Ngt8sN/Fa2zd\nhO0RFrTCHHMfZDGBbfYXdckyj0V4yb4bWsv7q1UzV1RgEYzFao+5jMOPbWBf\nmkJWUkeHV+sE5KQOFTf3uurQ9aKv6ENyuAPQVoCZC0JBNt0Nbommg8VhehM8\noYiHIc7USrqvsLCvmAywUplmV33eUHxLvWY3gC3gdazU6wsRLiTehN8xnCrx\nisunwtQHLQflF1CPi9XXGRD3f0kvqhgvykqn6dFjm3EwefzC9C0GYfyVEz/F\njFGm1m0LNXF+xQKwFzN//vdCKKpPRYodMddhabNPvCXKmijxBSgQ7DKejDH5\nozoe\r\n=afni\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHZyXAA3FIaoy0TQcWduHHR2UiAsZOyfqgmjJhPENbIoAiAfMOjBNEQoMLKxf0XXWl9IalPvyJCGQg4AGcCTThZXHQ=="}]},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chunkify_0.1.0_1611745723702_0.7977377557811702"},"_hasShrinkwrap":false},"0.2.0":{"name":"@sindresorhus/chunkify","version":"0.2.0","description":"Split an iterable into evenly sized chunks","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/chunkify.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["chunkify","chunk","chunks","chunked","chunking","array","iterable","iterator","generator","set","map","parts","split","size"],"devDependencies":{"ava":"^3.15.0","tsd":"^0.14.0","xo":"^0.37.1"},"gitHead":"f3267a348d57d5b7ec3aeee84b8c5ce46c9e3fd8","bugs":{"url":"https://github.com/sindresorhus/chunkify/issues"},"homepage":"https://github.com/sindresorhus/chunkify#readme","_id":"@sindresorhus/chunkify@0.2.0","_nodeVersion":"14.15.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-mOAiwqu+bIIkNFDCXFJxZEmF9p9WHfSBbpLLmgysYnNkEs7aA0/AvU9+6zLHFqI7JnqdqwAuWu8CbGwGIszRdw==","shasum":"b3a7b881e8e63e343a99a1cbf662687f4268a4d8","tarball":"https://registry.npmjs.org/@sindresorhus/chunkify/-/chunkify-0.2.0.tgz","fileCount":5,"unpackedSize":3846,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFArzCRA9TVsSAnZWagAA3tkP/0fYX5R2Qzm+lhLs+b/3\n5V1GZqh5/17xC05Cw8wTe4lQyIj6vrbSv75xXoV9vV+aV7693nK4JCsWUDy9\nFpYGknrCminWkKQoiS0Mmy/UlTV/lOkOAnfXsM2RdNe2RNWxABs72EM0Xz0T\nnvECTlduf85DFnkgiP0T9XzuKUhrXJ0AD2S3gfhZBeG2qR4CRrpNQ9oiak6s\nbrKsMNoPJXOFhL0S33KxBZKD+qdZgzEmql7zN6N+dpG6CdDsWzGIOyzzGbtj\n7ESxvHUWNiDX5WauexuTOY7dr7T5qe5f9V0PirjTprXmz/XsfNTvQoBtJWI/\nqx73GybMdUd0zDOwKsQJBK8aPDJqbpW3GFM2tM00IP9wAeZpI017/qc17hSJ\nRSog8e+6xF3gEXK1msBqTIGsvTsYA9yAadudUOAEGsUj+4ISDuv0v2y8fi22\nwL50pxbeqJnjcmD6AjWM2ZinyZC8Jb1L5Q+/7Snn7mUEOeNusCYDYv/rNpBp\nc4asr5UP+dwSQmhAbTEMVrE/DlIz8sJnJk9sIsvaTdSB3NWLrq/vkgSAYbB2\n8z+rHJeRTnqVoD3CQGKknVB03oUd9uJsn8imsPV1EuiwoVy2B31MNa19xWrH\nBpJ/jHXsAZtKgY0Ep0tV5fwisqpwtFv+0tpVyG3vRtXO9NTeFM5OjmRRPEU2\n6ePi\r\n=3wU3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBlr2BpkXqdLLSQBXmHCYThecvcFz59ewQZUd89mkvZxAiEAszPs5hbQibRQD52GMuZv/JYxRWVrGVLFsNFaKZd3pS0="}]},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chunkify_0.2.0_1611926258948_0.21324898957222738"},"_hasShrinkwrap":false},"1.0.0":{"name":"@sindresorhus/chunkify","version":"1.0.0","description":"Split an iterable into evenly sized chunks","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/chunkify.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"engines":{"node":">=18"},"scripts":{"test":"xo && ava && tsd"},"keywords":["chunkify","chunk","chunks","chunked","chunking","array","iterable","iterator","generator","set","map","parts","split","size","partition","divide","segment","batch","slice","subarray","group","allocate","dissect","segregate","separate","section"],"devDependencies":{"ava":"^5.3.1","tsd":"^0.29.0","xo":"^0.56.0"},"types":"./index.d.ts","gitHead":"a5e0c5aa3ebc597c8f7f1d5260b46dca28bbee2d","bugs":{"url":"https://github.com/sindresorhus/chunkify/issues"},"homepage":"https://github.com/sindresorhus/chunkify#readme","_id":"@sindresorhus/chunkify@1.0.0","_nodeVersion":"18.18.2","_npmVersion":"9.2.0","dist":{"integrity":"sha512-YJOcVaEasXWcttXetXn0jd6Gtm9wFHQ1gViTPcxhESwkMCOoA4kwFsNr9EGcmsARGx7jXQZWmOR4zQotRcI9hw==","shasum":"a0a596128ad43295be13e637308c03851bd42835","tarball":"https://registry.npmjs.org/@sindresorhus/chunkify/-/chunkify-1.0.0.tgz","fileCount":5,"unpackedSize":5264,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHuZEkZbll1zV4MtksOs+xP/7v4C2fm9efLK+6thTKxJAiAl25C6A++PAnUuzUJzfF6CGjXBN3kZQZV1u3gQvJB38Q=="}]},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chunkify_1.0.0_1699105881544_0.629258711797376"},"_hasShrinkwrap":false},"2.0.0":{"name":"@sindresorhus/chunkify","version":"2.0.0","description":"Split an iterable into evenly sized chunks","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/chunkify.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"engines":{"node":">=18"},"scripts":{"test":"xo && ava && tsd"},"keywords":["chunkify","chunk","chunks","chunked","chunking","array","iterable","iterator","generator","set","map","parts","split","size","partition","divide","segment","batch","slice","subarray","group","allocate","dissect","segregate","separate","section"],"devDependencies":{"ava":"^5.3.1","tsd":"^0.29.0","xo":"^0.56.0"},"types":"./index.d.ts","gitHead":"a5e0c5aa3ebc597c8f7f1d5260b46dca28bbee2d","bugs":{"url":"https://github.com/sindresorhus/chunkify/issues"},"homepage":"https://github.com/sindresorhus/chunkify#readme","_id":"@sindresorhus/chunkify@2.0.0","_nodeVersion":"21.2.0","_npmVersion":"9.2.0","dist":{"integrity":"sha512-srajPSoMTC98FETCJIeXJhJqB77IRPJSu8g907jLuuioLORHZJ3YAOY2DsP5ebrZrjOrAwjqf+Cgkg/I8TGPpw==","shasum":"3b6d87dd15dbac033ae56117fbe0b25641443579","tarball":"https://registry.npmjs.org/@sindresorhus/chunkify/-/chunkify-2.0.0.tgz","fileCount":5,"unpackedSize":5264,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFGaFMoUPg1sQzu6pL163wPxYWF7f5UK8lULwmaoMRdYAiEAif7s5ALI0I+fB1IgdftvkFZdNt6Qv3zVQFYwzEikXkw="}]},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chunkify_2.0.0_1703694774716_0.5707369201606007"},"_hasShrinkwrap":false,"deprecated":"Renamed to chunkify: https://www.npmjs.com/package/chunkify"}},"time":{"created":"2021-01-27T11:08:43.642Z","0.1.0":"2021-01-27T11:08:43.888Z","modified":"2023-12-27T16:33:42.630Z","0.2.0":"2021-01-29T13:17:39.126Z","1.0.0":"2023-11-04T13:51:21.762Z","2.0.0":"2023-12-27T16:32:54.895Z"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"description":"Split an iterable into evenly sized chunks","homepage":"https://github.com/sindresorhus/chunkify#readme","keywords":["chunkify","chunk","chunks","chunked","chunking","array","iterable","iterator","generator","set","map","parts","split","size","partition","divide","segment","batch","slice","subarray","group","allocate","dissect","segregate","separate","section"],"repository":{"type":"git","url":"git+https://github.com/sindresorhus/chunkify.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"bugs":{"url":"https://github.com/sindresorhus/chunkify/issues"},"license":"MIT","readme":"# chunkify\n\n> Split an iterable into evenly sized chunks\n\n## Install\n\n```sh\nnpm install @sindresorhus/chunkify\n```\n\n## Usage\n\n```js\nimport chunkify from '@sindresorhus/chunkify';\n\nconsole.log([...chunkify([1, 2, 3, 4], 2)]);\n//=> [[1, 2], [3, 4]]\n\nconsole.log([...chunkify([1, 2, 3, 4], 3)]);\n//=> [[1, 2, 3], [4]]\n```\n\n## API\n\n### chunkify(iterable, chunkSize)\n\nReturns an iterable with the chunks. The last chunk could be smaller.\n\n#### iterable\n\nType: `Iterable` *(for example, `Array`)*\n\nThe iterable to chunkify.\n\n#### chunkSize\n\nType: `number` *(integer)*\\\nMinimum: `1`\n\nThe size of the chunks.\n\n## Use-cases\n\n### Batch processing\n\nWhen dealing with large datasets, breaking data into manageable chunks can optimize the batch processing tasks.\n\n```js\nimport chunkify from '@sindresorhus/chunkify';\n\nconst largeDataSet = [...Array(1000).keys()];\nconst chunkedData = chunkify(largeDataSet, 50);\n\nfor (const chunk of chunkedData) {\n\tprocessBatch(chunk);\n}\n```\n\n### Parallel processing\n\nDividing data into chunks can be useful in parallel processing to distribute workload evenly across different threads or workers.\n\n```js\nimport {Worker} from 'node:worker_threads';\nimport chunkify from '@sindresorhus/chunkify';\n\nconst data = [/* some large dataset */];\nconst chunkedData = chunkify(data, 20);\n\nfor (const [index, chunk] of chunkedData.entries()) {\n\tconst worker = new Worker('./worker.js', {\n\t\tworkerData: {\n\t\t\tchunk,\n\t\t\tindex\n\t\t}\n\t});\n}\n```\n\n### Network requests\n\nSplitting a large number of network requests into chunks can help in managing the load on the network and preventing rate limiting.\n\n```js\nimport chunkify from '@sindresorhus/chunkify';\n\nconst urls = [/* Array of URLs */];\n\nconst chunkedUrls = chunkify(urls, 10);\n\nfor (const chunk of chunkedUrls) {\n\tawait Promise.all(chunk.map(url => fetch(url)));\n}\n```\n","readmeFilename":"readme.md"}