Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wankdanker/node-array-page
Get a page worth of records from an array
https://github.com/wankdanker/node-array-page
Last synced: 14 days ago
JSON representation
Get a page worth of records from an array
- Host: GitHub
- URL: https://github.com/wankdanker/node-array-page
- Owner: wankdanker
- Created: 2015-09-21T13:20:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-18T20:23:24.000Z (about 9 years ago)
- Last Synced: 2024-12-06T01:48:39.088Z (about 1 month ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
array-page
----------[![Build Status](https://travis-ci.org/wankdanker/node-array-page.svg)](https://travis-ci.org/wankdanker/node-array-page)
Get a page worth of records
example
-------```js
require('array-page').applyPrototype();
var a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];var page = a.page(/*page number*/ 2, /*page size*/ 3);
console.log(page);
// [1,2,3,4,5, _page: { page: 1, size: 5, count: 4, start: 0, stop: 5, first: 1, last: 4, next: 2, previous: null, total : 20 } ]```
install
-------```bash
npm install array-page
```api
---### arrayPage = require('array-page')
### arrayPage(array, pageNumber, pageSize)
* array: the array to get a page from
* pageNumber: the specific page of elements to return
* pageSize: the number of records to include in the page### arrayPage.applyPrototype()
Add a `page` method to the Array prototype
### arrayPage.defaults(opts);
* opts:
* pageSize : numeric; default page size. Default is 20;license
-------MIT