{"id":17817976,"url":"https://github.com/kjirou/simple-pagination","last_synced_at":"2025-03-18T04:30:41.743Z","repository":{"id":47452217,"uuid":"43292849","full_name":"kjirou/simple-pagination","owner":"kjirou","description":"Just provides only a simple pagination logic","archived":false,"fork":false,"pushed_at":"2021-08-31T07:29:02.000Z","size":5,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T03:34:03.888Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/kjirou.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":"2015-09-28T09:46:33.000Z","updated_at":"2019-07-01T20:33:41.000Z","dependencies_parsed_at":"2022-08-24T02:01:46.604Z","dependency_job_id":null,"html_url":"https://github.com/kjirou/simple-pagination","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjirou%2Fsimple-pagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjirou%2Fsimple-pagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjirou%2Fsimple-pagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjirou%2Fsimple-pagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kjirou","download_url":"https://codeload.github.com/kjirou/simple-pagination/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243910715,"owners_count":20367538,"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-10-27T16:47:00.303Z","updated_at":"2025-03-18T04:30:41.299Z","avatar_url":"https://github.com/kjirou.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-pagination\n\n[![npm version](https://badge.fury.io/js/simple-pagination.svg)](http://badge.fury.io/js/simple-pagination)\n[![Build Status](https://travis-ci.org/kjirou/simple-pagination.svg?branch=master)](https://travis-ci.org/kjirou/simple-pagination)\n\nJust provides only a simple pagination logic\n\n\n## Installation\n\n```\nnpm install --save simple-pagination\n```\n\n\n## API\n\n```js\n/*\n * Returns pagination result\n *\n * @param {number} totalCount    - Number of items that will be paginated\n * @param {number} perPage       - Number of items per page\n * @param {number} specifiedPage - Page number you wanted to get, it is started by 1\n */\nfunction paginate(totalCount, perPage, specifiedPage) {\n};\n```\n\n\n## Examples\n\n```js\nvar assert = require('assert');\nvar paginate = require('simple-pagination');\n\nassert.deepEqual(\n  paginate(25, 10, 1), {\n    totalCount: 25,\n    perPage: 10,\n    specifiedPage: 1,\n    pageCount: 3,\n    firstPage: 1,\n    lastPage: 3,\n    currentPage: 1,\n    isFirstPage: true,\n    isLastPage: false,\n    previousPage: null,\n    nextPage: 2,\n    fromCount: 1,\n    toCount: 10\n  }\n);\n\nassert.deepEqual(\n  paginate(25, 10, 3), {\n    totalCount: 25,\n    perPage: 10,\n    specifiedPage: 3,\n    pageCount: 3,\n    firstPage: 1,\n    lastPage: 3,\n    currentPage: 3,\n    isFirstPage: false,\n    isLastPage: true,\n    previousPage: 2,\n    nextPage: null,\n    fromCount: 21,\n    toCount: 25\n  }\n);\n\n// Specified page number is out of range\nassert.deepEqual(\n  paginate(25, 10, 4), {\n    totalCount: 25,\n    perPage: 10,\n    specifiedPage: 4,\n    pageCount: 3,\n    firstPage: 1,\n    lastPage: 3,\n    // currentPage is different from specifiedPage\n    currentPage: 3,\n    isFirstPage: false,\n    isLastPage: true,\n    previousPage: 2,\n    nextPage: null,\n    fromCount: 21,\n    toCount: 25\n  }\n);\n\n// If page count is 0, then props are mostly null\nassert.deepEqual(\n  paginate(0, 1, 1), {\n    totalCount: 0,\n    perPage: 1,\n    specifiedPage: 1,\n    pageCount: 0,\n    firstPage: null,\n    lastPage: null,\n    currentPage: null,\n    isFirstPage: null,\n    isLastPage: null,\n    previousPage: null,\n    nextPage: null,\n    fromCount: null,\n    toCount: null\n  }\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkjirou%2Fsimple-pagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkjirou%2Fsimple-pagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkjirou%2Fsimple-pagination/lists"}