1.0.1 • Published 9 years ago

offset-limit v1.0.1

Weekly downloads
1
License
Beerware
Repository
github
Last release
9 years ago

offset-limit

Convert various forms of querystring limit/offset, page, limit/range to database limit/offset.

Code was extracted from vanilla framework.

INSTALL

$ npm install --save offset-limit

USAGE

var offsetLimit = require("offset-limit");
offsetLimit("p1"); // => [0, 50]

API

offsetLimit(offsetOrPage, [limitOrSize, throwException])

offsetOrPage

Required
Type: string

The page query in one of the following formats:

  • p<x>: Get page x.
  • <x>-<y>: This is a range viewing records x through y.
  • <x>lim<n>: This is a limit/offset pair.
  • <x>: This is a limit where offset is given in the next parameter.

limitOrSize

Optional
Type: int
Default: 50

The page size or limit.

throwException

Optional
Type: boolean
Default: true

Throw exception if offsetOrPage unrecognized format passed.