Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/deiucanta/pagelist
Pagination logic/algorithm in Javascript
https://github.com/deiucanta/pagelist
algorithm javascript pagelist pagination paginator typescript
Last synced: 4 days ago
JSON representation
Pagination logic/algorithm in Javascript
- Host: GitHub
- URL: https://github.com/deiucanta/pagelist
- Owner: deiucanta
- License: mit
- Created: 2021-09-22T15:43:38.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-22T16:30:58.000Z (about 3 years ago)
- Last Synced: 2024-10-13T03:50:54.707Z (about 1 month ago)
- Topics: algorithm, javascript, pagelist, pagination, paginator, typescript
- Language: TypeScript
- Homepage:
- Size: 146 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pagelist
## Install
```
npm install pagelist
``````
yarn add pagelist
```## Usage
```js
import { pagelist } from 'pagelist';const current = 1;
const total = 500;
const display = 9;pagelist(current, total, display);
// => 1, 2, 3, 4, 5, 6, 7, _, 500
```## Examples
| Current | Total | Display | Result |
| ------- | ----- | ------- | --------------------------------------- |
| 1 | 1 | 10 | `[1]` |
| 1 | 10 | 10 | `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]` |
| 2 | 10 | 10 | `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]` |
| 1 | 1000 | 10 | `[1, 2, 3, 4, 5, 6, 7, 8, '-', 1000]` |
| 5 | 1000 | 10 | `[1, 2, 3, 4, 5, 6, 7, 8, '-', 1000]` |
| 6 | 1000 | 10 | `[1, '-', 4, 5, 6, 7, 8, 9, '-', 1000]` |
| 500 | 1000 | 7 | `[1, '-', 499, 500, 501, '-', 1000]` |
| 1000 | 1000 | 7 | `[1, '-', 996, 997, 998, 999, 1000` |
| 995 | 1000 | 7 | `[1, '-', 994, 995, 996, '-', 1000]` |