https://github.com/afeiship/next-chunk
Creates an array of elements split into groups the length of size.
https://github.com/afeiship/next-chunk
blob buffer chunk each each-slice file next slice
Last synced: 3 months ago
JSON representation
Creates an array of elements split into groups the length of size.
- Host: GitHub
- URL: https://github.com/afeiship/next-chunk
- Owner: afeiship
- License: mit
- Created: 2017-09-28T07:27:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-09-15T05:16:10.000Z (almost 3 years ago)
- Last Synced: 2025-03-17T22:55:53.515Z (3 months ago)
- Topics: blob, buffer, chunk, each, each-slice, file, next, slice
- Language: JavaScript
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# next-chunk
> Creates an array of elements split into groups the length of size.[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]## installation
```bash
npm install -S @jswork/next-chunk
```## apis
| api | type | description |
| -------- | ----------------- | ------------------- |
| nx.chunk | (inArray,inChunk) | Create split chunks |## usage
```js
import '@jswork/next-chunk';// array
const arr = [1,2,3,4,5,6,7,8];
const res = nx.chunk(arr, 3);
// result:
// [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8 ] ]// buffer/file
const file =new File(["foobar"], "foo.txt", {
type: "text/plain",
});// result:
const res = nx.chunk(file, 2);
// [ Blob, Blob, Blob ]
```## license
Code released under [the MIT license](https://github.com/afeiship/next-chunk/blob/master/LICENSE.txt).[version-image]: https://img.shields.io/npm/v/@jswork/next-chunk
[version-url]: https://npmjs.org/package/@jswork/next-chunk[license-image]: https://img.shields.io/npm/l/@jswork/next-chunk
[license-url]: https://github.com/afeiship/next-chunk/blob/master/LICENSE.txt[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-chunk
[size-url]: https://github.com/afeiship/next-chunk/blob/master/dist/next-chunk.min.js[download-image]: https://img.shields.io/npm/dm/@jswork/next-chunk
[download-url]: https://www.npmjs.com/package/@jswork/next-chunk