3.0.1 • Published 7 years ago

clay-list-pager v3.0.1

Weekly downloads
314
License
Apache-2.0
Repository
github
Last release
7 years ago

clay-list-pager

Build Status npm Version JS Standard

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

SignatureDescription
metaToPage() -> ObjectConvert clay collection meta object into page
pageToOffsetLimit(page, page.number, page.size) -> ObjectConvert 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.

Links