{"id":18782526,"url":"https://github.com/heppokofrontend/pager","last_synced_at":"2025-12-19T22:30:15.878Z","repository":{"id":57115736,"uuid":"388688352","full_name":"heppokofrontend/pager","owner":"heppokofrontend","description":"Wrapping iterable objects with the pager function.","archived":false,"fork":false,"pushed_at":"2021-07-23T09:53:37.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-26T01:41:25.891Z","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/heppokofrontend.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":"2021-07-23T05:32:23.000Z","updated_at":"2021-07-23T09:53:39.000Z","dependencies_parsed_at":"2022-08-23T03:40:52.583Z","dependency_job_id":null,"html_url":"https://github.com/heppokofrontend/pager","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heppokofrontend%2Fpager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heppokofrontend%2Fpager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heppokofrontend%2Fpager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heppokofrontend%2Fpager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heppokofrontend","download_url":"https://codeload.github.com/heppokofrontend/pager/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239699584,"owners_count":19682574,"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","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-07T20:36:17.870Z","updated_at":"2025-12-19T22:30:15.832Z","avatar_url":"https://github.com/heppokofrontend.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @heppokofrontend/pager\n\n[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE) [![Published on NPM](https://img.shields.io/npm/v/@heppokofrontend/pager.svg)](https://www.npmjs.com/package/@heppokofrontend/pager) [![test](https://github.com/heppokofrontend/pager/actions/workflows/ci.yml/badge.svg)](https://github.com/heppokofrontend/pager/actions/workflows/ci.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/027423b0daa8f7c001be/maintainability)](https://codeclimate.com/github/heppokofrontend/pager/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/027423b0daa8f7c001be/test_coverage)](https://codeclimate.com/github/heppokofrontend/pager/test_coverage) [![Known Vulnerabilities](https://snyk.io/test/npm/@heppokofrontend/pager/badge.svg)](https://snyk.io/test/npm/@heppokofrontend/pager)\n [![@heppokofrontend/pager](https://snyk.io/advisor/npm-package/@heppokofrontend/pager/badge.svg)](https://snyk.io/advisor/npm-package/@heppokofrontend/pager)\n\n\nWrapping iterable objects with the pager function.\n\n## Usage\n\n### Installation:\n\n```shell\nnpm install --save @heppokofrontend/pager\n```\n\n### Instance\n\n#### Properties\n\n|property name|type|readonly|description|\n|---|---|---|---|\n|`values`|`T[]`|`true`|Iterable objects to be managed by the pager.|\n|`views`|`number`||Number of items to be displayed per page.|\n|`set index()`|`number`||Page number to move to.|\n|`get index()`|`number`||The current page number.|\n|`get lastIndex()`|`number`|`true`|Last page number.|\n|`get page()`|`T[]`|`true`|Items on the current page.\u003cbr\u003eIt is recommended to cache the got values.|\n\n#### Methods\n\n|method name|type|description|\n|---|---|---|\n|`current()`|`(index: number) =\u003e T[]`|Switch the current page to any page.|\n|`next()`|`() =\u003e T[]`|Switch the current page to the next.|\n|`prev()`|`() =\u003e T[]`|Switch the current page to the previous.|\n\n\n### Syntax\n\n```js\nnew Pager(values[, views])\n```\n\n#### `values`\n\nAny iterable object.\n\n#### `views`\n\nIf specified, number of items to be displayed per page.\n\nThe default value is `5`.\n\n### Example:\n\n```javascript\nimport { Pager } from '@heppokofrontend/pager';\n// const { Pager } = require('@heppokofrontend/pager');\n\nconst pager = new Pager([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);\n\npager.current(1); // =\u003e [6, 7, 8, 9, 10]\npager.current(-1); // =\u003e [1, 2, 3, 4, 5]\npager.current(pager.lastIndex); // =\u003e [6, 7, 8, 9, 10]\npager.current(100); // =\u003e [6, 7, 8, 9, 10]\npager.lastIndex // =\u003e 2\n\npager.views = 2; // Change the number of views per page.\n\npager.lastIndex // =\u003e 5\npager.current(1); // =\u003e [3, 4]\npager.current(200); // =\u003e [9, 10]\npager.page // =\u003e [9, 10]\n\npager.index = 3; // Change the current page number\n\npager.page // =\u003e [7, 8]\npager.current(7); // =\u003e [7, 8]\n```\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n## License\n\nMIT\n\n## 元ネタ\n\nhttps://qiita.com/heppokofrontend/items/52d95a11c5e5ee4f1ca6\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheppokofrontend%2Fpager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheppokofrontend%2Fpager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheppokofrontend%2Fpager/lists"}