offset-limit

1.0.1 • Public • Published

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.

/offset-limit/

    Package Sidebar

    Install

    npm i offset-limit

    Weekly Downloads

    0

    Version

    1.0.1

    License

    Beerware

    Last publish

    Collaborators

    • iamthes