ts-pagination
TypeScript icon, indicating that this package has built-in type declarations

3.0.1 • Public • Published

ts-pagination Build Status npm

Pagination for Nodejs and JavaScript..

🔥🔥🔥 Break Change 🔥🔥🔥

I rewrite it to 3.0 making performance better and size smaller. So if you use 3.0 above, please check "How to use" section again.

Install

$ npm install ts-pagination --save

How to use

import { getSimplePagination } from "ts-pagination";

const data = [
  { id: "1", name: "bb0", age: 25 },
  { id: "2", name: "bb1", age: 26 },
  { id: "3", name: "bb2", age: 27 },
  { id: "4", name: "bb3", age: 28 },
  { id: "5", name: "bb4", age: 29 },
  { id: "6", name: "bb5", age: 210 },
];

const sPagination = getSimplePagination(
  {
    currentPage: 1,
    size: 5,
    total: data.length,
  },
  3,
  {
    firstText: "first",
    lastText: "last",
    preGroupText: "<<",
    nextGroupText: ">>",
    PreText: "<",
    nextText: ">",
    isShowFirstLastItem: true,
    isShowPrevNextGroupItem: true,
    isShowPrevNextItem: true,
  }
);
console.log(sPagination);

Demo

image

playground

Todos

  • [x] UI demo
  • [x] testing
  • [ ] middle pagination

Code Coverage

-------------------------|---------|----------|---------|---------|-------------------
File                     | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------------|---------|----------|---------|---------|-------------------
All files                |     100 |      100 |     100 |     100 |
 src                     |     100 |      100 |     100 |     100 |
  _index.ts              |     100 |      100 |     100 |     100 |
 src/code                |     100 |      100 |     100 |     100 |
  core.ts                |     100 |      100 |     100 |     100 |
  getSimplePagination.ts |     100 |      100 |     100 |     100 |
-------------------------|---------|----------|---------|---------|-------------------

Workspace

docker run --rm -it \
  -w /app \
  -v $(pwd):/app \
  -p 3000:3000 \
  -p 10000:10000 \
  -p 24678:24678 \
  node:16.19-alpine /bin/sh

apk add --no-cache bash &&\
	npm i -g pnpm

Package Sidebar

Install

npm i ts-pagination

Weekly Downloads

5

Version

3.0.1

License

MIT

Unpacked Size

88.4 kB

Total Files

64

Last publish

Collaborators

  • bibbychung