Paginate an array into pages of items.
npm install paginationatorPaginate an array into pages of items.
Install with npm:
``sh`
$ npm install --save paginationator
`js`
var paginationator = require('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 paginateoptions
* {Object}: Additional options to control paginationoptions.limit
* {Number}: Number of items per page (defaults to 10)returns
* {Object}: paginated pages
Example
`js`
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 constructor
Params
* page {Object}: optional page object to populate initial values.
Example
`js`
var page = new Page();
Pages constructor
Params
* pages {Array}: Optional array of pages to initialize the pages array.
Example
`js`
var pages = new Pages();
Add a page to the list.
Params
* page {Object}: Plain object or instance of a Pagereturns
* {Object}: Returns the instance for chaining
Example
`js`
pages.addPage({items: [1, 2, 3]});
Add an array of pages to the list.
Params
* pages {Object}: Array of page objectsreturns
* {Object}: Returns the instance for chaining
Example
`js`
pages.addPages([...]);
* assemble: Get the rocks out of your socks! Assemble makes you fast at creating web projects… 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
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
_(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)_
To generate the readme and API documentation with verb:
`sh`
$ npm install -g verb verb-generate-readme && verb
Install dev dependencies:
`sh``
$ npm install -d && npm test
Brian Woodward
Copyright © 2016, Brian Woodward.
Released under the MIT license.
*
_This file was generated by verb, v0.9.0, on July 19, 2016._