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

paginationator

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paginationator

Paginate an array into pages of items.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
31K
increased by0.88%
Maintainers
1
Weekly downloads
 
Created
Source

paginationator NPM version Build Status

Paginate an array into pages of items.

Install with npm

$ npm i paginationator --save

Usage

var paginationator = require('paginationator');

API

paginationator

Paginate an array with given options and return a Page object containing an array of pages with pagination information.

Params

  • arr {Array}: Array of items to paginate
  • options {Object}: Additional options to control pagination
  • options.limit {Number}: Number of items per page (defaults to 10)
  • returns {Object}: paginated pages

Example

var pages = paginationator([1, 2, 3, 4, 5], {limit: 2});
//=> { pages: [
//=>   { idx: 0, total: 3, current: 1, items: [1, 2], first: 1, last: 3, next: 2 },
//=>   { idx: 1, total: 3, current: 2, items: [3, 4], first: 1, last: 3, prev: 1, next: 3 },
//=>   { idx: 2, total: 3, current: 3, items: [5], first: 1, last: 3, prev: 2 }
//=> ]}

Page

Page constructor

Params

  • page {Object}: optional page object to populate initial values.

Example

var page = new Page();

Pages

Pages constructor

Params

  • pages {Array}: Optional array of pages to initialize the pages array.

Example

var pages = new Pages();

.addPage

Add a page to the list.

Params

  • page {Object}: Plain object or instance of a Page
  • returns {Object}: Returns this for chaining

Example

pages.addPage({items: [1, 2, 3]});
  • assemble: Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… more | homepage
  • template: Render templates using any engine. Supports, layouts, pages, partials and custom template types. Use template… more | homepage
  • templates: System for creating and managing template collections, and rendering templates with any node.js template engine.… more | homepage
  • verb: Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… more | homepage

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Brian Woodward

License

Copyright © 2015 Brian Woodward Released under the MIT license.


This file was generated by verb-cli on September 10, 2015.

FAQs

Package last updated on 10 Sep 2015

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