clay-list-pager
v3.0.1
Published
List pager for ClayDB
Downloads
34
Readme
clay-list-pager
List pager for ClayDB
Installation
$ npm install clay-list-pager --save
Usage
'use strict'
const { paginateArray } = require('clay-list-pager')
{
let array = [ { id: 1 }, { id: 2 }, { id: 3 } ]
let page = { number: 2, size: 2 }
let paginated = paginateArray(array, page)
console.log(paginated) // -> [ { id: 3 } ]
}
Functions
Available functions
| Signature | Description |
| ---- | ----------- |
| metaToPage() -> Object
| Convert clay collection meta object into page |
| pageToOffsetLimit(page, page.number, page.size) -> Object
| Convert page into offset/limit |
| paginateArray(array, page, page.number, page.size) -> Object[]
| Paginate array with paging condition |
License
This software is released under the Apache-2.0 License.