Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

arrpag

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arrpag

Paginate the array

  • 2.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status Coverage Status GitHub issues GitHub forks GitHub stars GitHub license

simple-pagination

Simple pagination module for arrays.

Usage

1. Instalation

npm install arrpag --save
yarn add arrpag
bower install arrpag --save

2. Return object

The return object is an object of this format:

/**
 * @property currentPage - the current page - number
 * @property nextPage - the next page - number
 * @property prevPage - the previous page - number
 * @property perPage - number of elements per page
 * @property pages - total number of available pages
 * @property results - the paginated sub-array from the given array
 * @property totalCurrentResults - total number of current paginated items
 * @property totalResults - total number of results -> should be the initial array lengt
 */
export interface IPaginationResult {
  totalResults: number;
  results: any[];
  pages: number;
  currentPage: number;
  prevPage: number;
  nextPage: number;
  perPage: number;
  totalCurrentResults: number;
}

3. Usage

Javascript

const paginator = require("arrpag");

// ...

const arr = [1, 2, 3, 4, 5];

const paginationResult = paginator.paginate(arr, 2, 3);

Typescript

import { paginate } from "arrapg";

// ...

const arr = [1, 2, 3, 4, 5];

const paginationResult = paginate(arr, 2, 3);

AMD

define(function(require, exports, module) {
  var paginate = require("arrpag");
});

For the previous example the output should be:

{
  totalResults: 5,
  results: [ 4, 5 ],
  pages: 2,
  currentPage: 2,
  prevPage: 1,
  nextPage: 2,
  perPage: 3,
  totalCurrentResults: 2
}

4. Test

npm run test

Keywords

FAQs

Package last updated on 25 Oct 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc