Paginate an array into pages of items.
![image](https://cloud.githubusercontent.com/assets/995160/9802527/ca15f300-57e8-11e5-96db-523ea5a0572e.png)
Install
Install with npm
$ npm i paginationator --save
Usage
var paginationator = require('paginationator');
API
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
var pages = paginationator([1, 2, 3, 4, 5], {limit: 2});
Page constructor
Params
page
{Object}: optional page object to populate initial values.
Example
var page = new Page();
Pages constructor
Params
pages
{Array}: Optional array of pages to initialize the pages
array.
Example
var pages = new Pages();
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]});
Related projects
- assemble: Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… more | homepage
- base-methods: base-methods is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… 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 on December 20, 2015.