0.1.1 • Published 4 years ago

@pelevesque/paginate v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

paginate

Makes useful calculations for creating website pagination links.

Node Repository

https://www.npmjs.com/package/@pelevesque/paginate

Installation

npm install @pelevesque/paginate

Tests

CommandDescription
npm test or npm run teststandardx + unit tests
npm run coverunit tests + coverage
npm run standardxstandardx
npm run unitunit tests

Usage

const paginate = require('@pelevesque/paginate')
const numLinks = 10 // number of links to others pages
const currentPage = 3
const numItemsPerPage = 10
const numItems = 300
const url = 'http://www.localhost.com/?page='

const paginateObject = paginate(numLinks, currentPage, numItemsPerPage, numItems, url)

// result
paginateObject = {
  numLinks: 10,
  currentPage: 3,
  numItemsPerPage: 10,
  numItems: 300,
  url: 'www.localhost.com/?page=',
  links: [
    { page: 1,  active: false, url: 'www.localhost.com/?page=1'  },
    { page: 2,  active: false, url: 'www.localhost.com/?page=2'  },
    { page: 3,  active: true,  url: 'www.localhost.com/?page=3'  },
    { page: 4,  active: false, url: 'www.localhost.com/?page=4'  },
    { page: 5,  active: false, url: 'www.localhost.com/?page=5'  },
    { page: 6,  active: false, url: 'www.localhost.com/?page=6'  },
    { page: 7,  active: false, url: 'www.localhost.com/?page=7'  },
    { page: 8,  active: false, url: 'www.localhost.com/?page=8'  },
    { page: 9,  active: false, url: 'www.localhost.com/?page=9'  },
    { page: 10, active: false, url: 'www.localhost.com/?page=10' },
  ],
  firstPageLink: 1,
  lastPageLink: 10,
  firstPage: 1,
  lastPage: 30,
  numPreviousPages: 2,
  numFollowingPages: 27,
}

Integration with Adonis.js

https://github.com/adonisjs/core/discussions/1381

Copyright

Copyright (c) 2018-2020, Pierre-Emmanuel Lévesque

License

MIT

0.1.1

4 years ago

0.1.0

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

6 years ago

0.0.1

6 years ago