JSPM

page-hopper

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q25714F
  • License MIT

Efficient and easy-to-use pagination utility for JavaScript arrays, suitable for Node.js and browser environments.

Package Exports

  • page-hopper
  • page-hopper/src/paginate.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (page-hopper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

page-hopper

A simple and efficient pagination utility for arrays in JavaScript, suitable for both Node.js and browser environments.

Installation

npm install page-hopper

Usage

Basic Usage

const paginate = require('page-hopper');
const collection = [/* your array data */];

const pageNumber = 1;
const numItemsPerPage = 10;
const paginatedCollection = paginate(collection, pageNumber, numItemsPerPage);

console.log(paginatedCollection);

This will output:

{
  currentPage: 1,
  perPage: 10,
  total: 30,
  totalPages: 3,
  data: [/* paginated items */]
}

With Custom Options

const customOptions = { customKey: 'customValue' };
const paginatedCollection = paginate(collection, pageNumber, numItemsPerPage, customOptions);

console.log(paginatedCollection);

This will output:

{
  currentPage: 1,
  perPage: 10,
  total: 30,
  totalPages: 3,
  data: [/* paginated items */],
  customKey: 'customValue'
}

Features

  • Simple and easy to use.
  • No external dependencies.
  • Customizable pagination.