new pages(data, size) → {class}
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | Array | Input the array or object that is going to be used for spliting into pages |
size |
number | Specify how much elements can be in one page |
Returns:
this - Returns this class
- Type
- class
Members
MaxPages
Check how much pages are there
Methods
ArrayPages() → {Array}
Returns the obj/array splited into pages in array format
Returns:
Returns array that contains elements splited into pages
- Type
- Array
GetPageContent(page) → {object|array}
Get contents of specific page
Parameters:
Name | Type | Description |
---|---|---|
page |
number | Page number to get |
Returns:
- Returns one page
- Type
- object | array
Example
const pages = require('split-into-pile')([2,5,6,8], 2);
pages.GetPageContent(2); // Returns [6, 8]
ObjectPages(options) → {Object}
Returns the obj/array splited into pages in object format
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | Options for output
Properties
|
Returns:
Returns array that contains elements splited into pages
- Type
- Object
Examples
- KeyTemplate
ObjectPages({ keyTemplate: '#{number}' }); // "Number" will be auto replaced with the numeric order of the elements
- KeySchema
const pages = require('split-into-pile')([2,4,3,5], 2);
pages.ObjectPages({ keySchema: ['hello', 'example'] }); // Returns {'hello':[2,4], 'example': [3,5]}
PageExist(page) → {boolean}
Check if a page exists
Parameters:
Name | Type | Description |
---|---|---|
page |
number | Page number |
Returns:
- Returns if the page exists
- Type
- boolean