{"id":23605747,"url":"https://github.com/rodzyk/pair-pagination","last_synced_at":"2026-01-27T09:17:52.753Z","repository":{"id":264233698,"uuid":"892801552","full_name":"rodzyk/pair-pagination","owner":"rodzyk","description":"A TypeScript utility for generating page pairs in pagination, with customizable options like pair limit and flat structure.","archived":false,"fork":false,"pushed_at":"2024-11-22T20:05:19.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-21T23:39:00.112Z","etag":null,"topics":["npm","npm-package","page-navigation","page-pairs","pagination","pagination-helper","pagination-helpers","pair-pagination","typescript","utility"],"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/rodzyk.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-22T20:05:06.000Z","updated_at":"2024-12-01T09:49:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"a26ab959-93a7-454e-90a1-aa64e27d0a05","html_url":"https://github.com/rodzyk/pair-pagination","commit_stats":null,"previous_names":["rodzyk/pair-pagination"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rodzyk/pair-pagination","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodzyk%2Fpair-pagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodzyk%2Fpair-pagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodzyk%2Fpair-pagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodzyk%2Fpair-pagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rodzyk","download_url":"https://codeload.github.com/rodzyk/pair-pagination/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodzyk%2Fpair-pagination/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28810475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T07:41:26.337Z","status":"ssl_error","status_checked_at":"2026-01-27T07:41:08.776Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["npm","npm-package","page-navigation","page-pairs","pagination","pagination-helper","pagination-helpers","pair-pagination","typescript","utility"],"created_at":"2024-12-27T13:12:50.969Z","updated_at":"2026-01-27T09:17:52.744Z","avatar_url":"https://github.com/rodzyk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pair Pagination\n\n**Pair Pagination** is a simple TypeScript utility for generating page pairs in pagination. It allows you to create customizable pagination structures with options like pair limits and flat or nested outputs.\n\n---\n\n## Features\n\n- **Generate Page Pairs:** Create pairs of pages for easy navigation in paginated content.\n- **Customizable Options:** Configure pair limits, flat or nested output formats, and more.\n- **TypeScript Support:** Fully typed for seamless integration with TypeScript projects.\n- **Lightweight and Simple:** Easy to use and requires minimal setup.\n\n---\n\n## Installation\n\nInstall the library using npm:\n\n```bash\nnpm i pair-pagination\n```\n\n## Usage\n\n### Import and Use\n\n```typescript\nimport { pairPagination } from 'pair-pagination';\n\nconst pairs = pairPagination({ \n    currentPage: 4, \n    totalPages: 10, \n    flat: false \n});\n\nconsole.log(pairs); \n// Output: [1, [2, 3], [4, 5], [6, 7], [8, 9], 10]\n```\n\n### API\n\n#### `pairPagination(options: PaginationOptions): PairPagination`\n\nGenerates page pairs based on the provided pagination options.\n\n`PaginationOptions`:\n\n- `currentPage` (number): The currently active page.\n- `totalPages` (number): Total number of pages.\n- `pairLimit` (number, optional): The number of pairs to display around the current page. Default is `1`.\n- `flat` (boolean, optional): If true, flattens the output into a single array. Default is `true`.\n\nReturns:\n\n- `PagePairs`: An array of numbers or pairs of numbers.\n\n#### `pairPaginationByItems(option: PairPaginationByItemsOption): PairPagination `\n\nGenerates page pairs based on the total number of items and items per page.\n\n`PairPaginationByItemsOption`:\n\n- `totalItems` (number): Total number of items.\n- `limitItems` (number): Number of items per page.\n- `currentPage` (number): The currently active page.\n- `pairLimit` (number, optional): The number of pairs to display around the current page. Default is `1`.\n- `flat` (boolean, optional): If true, flattens the output into a single array. Default is `true`.\n\nReturns:\n\n- `PagePairs`: An array of numbers or pairs of numbers.\n\n## Testing\n\nRun tests using Jest:\n\n```bash \nnpm test\n```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request on the GitHub repository.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodzyk%2Fpair-pagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodzyk%2Fpair-pagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodzyk%2Fpair-pagination/lists"}