npm.io
1.0.4 • Published 4 years ago

pagelist

Licence
MIT
Version
1.0.4
Deps
0
Size
14 kB
Vulns
0
Weekly
0

Pagelist

Install

npm install pagelist
yarn add pagelist

Usage

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]