{"id":19837077,"url":"https://github.com/smaug6739/array-paginator","last_synced_at":"2026-03-08T14:33:21.422Z","repository":{"id":46712214,"uuid":"355904892","full_name":"Smaug6739/array-paginator","owner":"Smaug6739","description":"This module is a paginator of arrays for simplify the pagination with arrays. This module split yours arrays in pages and you can recover this pages.","archived":false,"fork":false,"pushed_at":"2022-10-24T17:46:39.000Z","size":54,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-28T03:02:43.357Z","etag":null,"topics":["array","pager","pages","paginator"],"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/Smaug6739.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-04-08T12:48:28.000Z","updated_at":"2023-08-24T03:44:39.000Z","dependencies_parsed_at":"2023-01-20T07:52:18.756Z","dependency_job_id":null,"html_url":"https://github.com/Smaug6739/array-paginator","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/Smaug6739%2Farray-paginator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smaug6739%2Farray-paginator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smaug6739%2Farray-paginator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smaug6739%2Farray-paginator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Smaug6739","download_url":"https://codeload.github.com/Smaug6739/array-paginator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251924574,"owners_count":21665993,"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":["array","pager","pages","paginator"],"created_at":"2024-11-12T12:13:27.572Z","updated_at":"2026-03-08T14:33:21.374Z","avatar_url":"https://github.com/Smaug6739.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Paginator of arrays\n\n![NPM](https://nodei.co/npm/array-paginator.png)\n\n![[NPM package](https://www.npmjs.com/package/array-paginator)](https://badge.fury.io/js/array-paginator.svg)\n![[LICENSE](https://github.com/Smaug6739/array-paginator.js/blob/master/LICENSE)](https://img.shields.io/github/license/Smaug6739/array-paginator.svg)\n\nThis module is a paginator of arrays for simplify the pagination with arrays.  \nThis module split yours arrays in pages and you can recover this pages.\n\n## Getting started\n\n### Installation\n\nWith npm :\n\n```sh-session\nnpm install array-paginator\n```\n\nWith yarn :\n\n```sh-session\nyarn add array-paginator\n```\n\n### Import module\n\nWith CommonJS syntax :\n\n```js\nconst { Paginator } = require(\"array-paginator\");\n```\n\nWith module syntax :\n\n```js\nimport { Paginator } from \"array-paginator\";\n```\n\n## Usage\n\nCreate a new Paginator with an array as a parameter and two optionals parameters : max items per page (default:5) and current page (default:1) :\n\n```js\nconst paginator = new Paginator(data, 15, 1);\n```\n\n## Paginator#push(newData)\n\nPush data in array.\n\nParameters :\n\n- newData : A new data (type : `any`).\n\nType : Boolean\n\n```js\npaginator.push(data); // Push data\n```\n\n## Paginator#set(newData)\n\nSet data in array.\n\nParameters :\n\n- newData : An array with new data (type : `Array\u003cany\u003e`).\n\nType : Boolean\n\n```js\npaginator.set(data); // Set data\n```\n\n## Paginator#clear(newData)\n\nClear data in array.\n\nParameters :\n\n- newData : An array with new data (type : `Array\u003cany\u003e`).\n\nType : Boolean\n\n```js\npaginator.clear(data); // Clear data\n```\n\n## Paginator#page(page)\n\nReturn a specific page.\n\nParameters :\n\n- page : The page to get (type : `number`)\n\nType : Array\n\n```js\nconst page = paginator.page(1); // Get page one\n```\n\n## Paginator#first()\n\nReturn the first page.\n\nType : Array\n\n```js\nconst firstPage = paginator.first(); // Get first page\n```\n\n## Paginator#last()\n\nReturn the last page.\n\nType : Array\n\n```js\nconst lastPage = paginator.last(); // Get last page\n```\n\n## Paginator#next()\n\nReturn the next page.\n\nType : Array\n\n```js\nconst nextPage = paginator.next(); // Get next page\n```\n\n## Paginator#previous()\n\nReturn the previous page.\n\nType : Array\n\n```js\nconst previousPage = paginator.previous(); // Get previous page\n```\n\n## Paginator#hasFirst()\n\nReturn true if first page exist.\n\nType : Boolean\n\n```js\nconst previousPage = paginator.previous(); // Get previous page\n```\n\n## Paginator#hasNext()\n\nReturn true if next page exist.\n\nType : Boolean\n\n```js\nconst hasNextPage = paginator.hasNext(); // true if next page exists\n```\n\n## Paginator#hasPrevious()\n\nReturn true if previous page exist.\n\nType : Boolean\n\n```js\nconst hasPreviousPage = paginator.hasPrevious(); // true if previous page exists\n```\n\n## Paginator#hasLast()\n\nReturn true if last page exist.\n\nType : Boolean\n\n```js\nconst hasLastPage = paginator.hasLast(); // true if last page exists\n```\n\n## Properties\n\n---\n\n## Paginator.current\n\nThe current page.  \nType : Number\n\n## Paginator.all\n\nReturn all data.  \nType : Array\n\n## total\n\nThe total of pages.  \nType : Number\n\n## Example\n\n```js\nconst { Paginator } = require(\"array-paginator\");\nconst data = Array.from(new Array(50).keys());\nconst pager = new Paginator(data, 10);\n\npager.page(2); // [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\npager.first(); // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\npager.last(); // [40, 41, 42, 43, 44, 45, 46, 47, 48, 49]\npager.next(); // [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\npager.previous(); // undefined\npager.hasNext(); // true\npager.hasPrevious(); // false\n\npager.current; //5\npager.all; // [0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, ... 49]\npager.total; //5\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmaug6739%2Farray-paginator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmaug6739%2Farray-paginator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmaug6739%2Farray-paginator/lists"}