{"id":19050483,"url":"https://github.com/blakek/array-split","last_synced_at":"2025-07-29T17:11:43.479Z","repository":{"id":38249507,"uuid":"270435817","full_name":"blakek/array-split","owner":"blakek","description":"💔 Split and chunk arrays, strings, and more","archived":false,"fork":false,"pushed_at":"2023-01-06T08:16:45.000Z","size":1590,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-22T14:54:07.881Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blakek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-07T21:20:21.000Z","updated_at":"2021-10-21T12:28:59.000Z","dependencies_parsed_at":"2023-02-05T16:46:49.285Z","dependency_job_id":null,"html_url":"https://github.com/blakek/array-split","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/blakek/array-split","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakek%2Farray-split","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakek%2Farray-split/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakek%2Farray-split/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakek%2Farray-split/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blakek","download_url":"https://codeload.github.com/blakek/array-split/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakek%2Farray-split/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267723148,"owners_count":24134077,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T23:15:05.258Z","updated_at":"2025-07-29T17:11:43.419Z","avatar_url":"https://github.com/blakek.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# array-split\n\n\u003e 💔 Split and chunk arrays, strings, and more\n\nFunctions to help split an array at an index and chunk an array into pieces.\n\n## Install\n\nUsing [Yarn]:\n\n```bash\n$ yarn add @blakek/array-split\n```\n\n…or using [npm]:\n\n```bash\n$ npm i --save @blakek/array-split\n```\n\n## API\n\n### `chunk`\n\n```ts\nfunction chunk\u003cT extends Sliceable\u003e(chunkSize: number, array: T): T[];\n```\n\nChunks an array into pieces of a given size.\n\n```js\nimport { chunk } from '@blakek/array-split';\n\nchunk(2, [1, 2, 3, 4]);\n//» [[1, 2], [3, 4]]\n\nchunk(3, 'abcdefghij');\n//» ['abc', 'def', 'ghi', 'j']\n\nchunk(3, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);\n//» [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11]]\n```\n\n### `splitAtIndex`\n\n```ts\nfunction splitAtIndex\u003cT extends Sliceable\u003e(index: number, array: T): T[];\n```\n\nSplits an array into two pieces at the given index. Anything below the index is\nin the first array, the index and above are the second array.\n\nNote, you may pass a negative index to split at the end of the array.\n\n```js\nimport { splitAtIndex } from '@blakek/array-split';\n\nsplitAtIndex(0, [1, 2, 3, 4]);\n//» [[], [1, 2, 3, 4]]\n\nsplitAtIndex(1, [1, 2, 3, 4]);\n//» [[ 1 ], [2, 3, 4]]\n\nsplitAtIndex(-1, ['a', 'b', 'c']);\n//» [[ 'a', 'b' ], ['c']]\n\nsplitAtIndex(3, ['a', 'b', 'c', 'd', 'e']);\n//» [['a', 'b', 'c'], ['d', 'e']]\n\nsplitAtIndex(1, 'abc');\n//» ['a', 'bc']\n```\n\n### `splitAtIndices`\n\n```ts\nfunction splitAtIndices\u003cT extends Sliceable\u003e(\n  [index, nextIndex, ...indices]: number[],\n  array: T\n): T[];\n```\n\nSimilar to `splitAtIndex` but slices an array at multiple indices.\n\n```js\nimport { splitAtIndices } from '@blakek/array-split';\n\nsplitAtIndices([1, 3], ['a', 'b', 'c', 'd', 'e']);\n//» [['a'], ['b', 'c'], ['d', 'e']]\n\nsplitAtIndices([2, 5], 'blakek');\n//» ['bl', 'ake', 'k']\n\nsplitAtIndices([-4, -1], 'github');\n//» ['gi', 'thu', 'b']\n```\n\n## Contributing\n\n[Node.js] and [Yarn] are required to work with this project.\n\nTo install all dependencies, run:\n\n```bash\nyarn\n```\n\n### Useful Commands\n\n|                     |                                                 |\n| ------------------- | ----------------------------------------------- |\n| `yarn build`        | Builds the project to `./dist`                  |\n| `yarn format`       | Format the source following the Prettier styles |\n| `yarn test`         | Run project tests                               |\n| `yarn test --watch` | Run project tests, watching for file changes    |\n\n## License\n\nMIT\n\n[node.js]: https://nodejs.org/\n[npm]: https://npmjs.com/\n[yarn]: https://yarnpkg.com/en/docs/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakek%2Farray-split","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblakek%2Farray-split","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakek%2Farray-split/lists"}