1.0.0 • Published 5 years ago

object-pager v1.0.0

Weekly downloads
3
License
GPL-3.0
Repository
github
Last release
5 years ago

object-pager

Split an object into an array of pages.

Usage

var Paginate = require('object-pager');

var objects = {"a": "b", "c": "d", "e": "f", "g": "h", "i": "j", "k": "l", "m": "n", "o": "p", "q": "r", "s": "t"};

console.log(Paginate(objects, 3));
// [{"a": "b", "c": "d", "e": "f"},
//  {"g": "h", "i": "j", "k": "l"},
//  {"m": "n", "o": "p", "q": "r"},
//  {"s": "t"}]

console.log(Paginate({objects}, 10));
// [{"a": "b", "c": "d", "e": "f", "g": "h", "i": "j", "k": "l", "m": "n", "o": "p", "q": "r", "s": "t"}]

console.log(Paginate({"a": "b", "c": "d", "e": "f"}, 10));
// [{"a": "b", "c": "d", "e": "f"}]

console.log(0);
// Error: Object (first argument) is not of type "object".

console.log(objects, 0);
// Error: Pages must contain at least one object.