🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

pagesify

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pagesify

Simple pagination algorithm

latest
Source
npmnpm
Version
2.0.1
Version published
Maintainers
1
Created
Source

pagesify Build Status

Simple pagination algorithm

Requirements

  • node.js

Install

$ npm install --save pagesify

Usage

import Pagesify from 'pagesify';

const pagesify = new Pagesify({
    interval: 3,
    placeholder: '..',
    itemsPerPage: 3,
});

const items = [
    'radiohead',
    'jamie woon',
    'actress',
    'joy division',
    'burial',
    'sampha',
    'the xx',
    'nicolas jaar',
    'boards of canada',
    'james blake',
    'nicolas jaar',
    'apparat',
    'clark',
];

const currentPage = 3;

const pagination = pagesify.paginate(items, currentPage);

console.log(pagination.handles);
// { handles: [ 'prev', 1, 2, 3, '..', 5, 'next' ] }

console.log(pagination.pages);
/* pages:
 { '1': [ 'radiohead', 'jamie woon', 'actress' ],
   '2': [ 'joy division', 'burial', 'sampha' ],
   '3': [ 'the xx', 'nicolas jaar', 'boards of canada' ],
   '4': [ 'james blake', 'nicolas jaar', 'apparat ],
   '5': [ 'clark' ],
   length: 5 } }
*/

TypeScript

This library is written in TypeScript and includes type definitions. The interfaces are automatically available when importing:

import Pagesify, { PagesifyOptions, PaginationResult, Pages } from 'pagesify';

const options: PagesifyOptions = {
    interval: 3,
    placeholder: '..',
    itemsPerPage: 3,
};

const pagesify = new Pagesify(options);
const result: PaginationResult = pagesify.paginate(items, 3);

API

OPTIONS

  • interval(default=3) - how many pages shown in between the current page
  • placeholder(default='..') - which symbol represents the interval of pages that isn't shown
  • itemsPerPage(default=2) - how many items are there in each page

createPageHandles (pages, currentPage)

pages: object starting from 1
currentPage: number

Returns an array of handles

convertListToPages (list, itemsPerPage)

list: object starting from 1
itemsPerPage: number

Returns an object of pages

License

MIT © Ricardo Matias

FAQs

Package last updated on 18 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts