object-pager

1.0.0 • Public • Published

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.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i object-pager

      Weekly Downloads

      0

      Version

      1.0.0

      License

      GPL-3.0

      Unpacked Size

      38.2 kB

      Total Files

      4

      Last publish

      Collaborators

      • chlodalejandro