0.3.0 • Published 7 years ago

drf-paginator v0.3.0

Weekly downloads
70
License
MIT
Repository
github
Last release
7 years ago

drf-paginator

JavaScript module for consuming paginated Django REST framework endpoints.

npm Version MIT License Build Status Coverage Dependencies Status devDependencies Status

Usage

The paginator separates pagination logic from each individual request to the endpoint.

import drfp from 'drf-paginator';

Each request to the endpoint is handled by a request function. Request functions are provided with options and query parameters to make requests. They in turn return promises for the response body.

let request = function(options, queryParams) {
  return Promise<ResponseBody>;
}

Each paginator is provided with a request function to send requests.

let paginator = drfp.paginate(request);

Paginator's provide an interface for pagination while caching requests.

paginator.next()
  .then((responseBody) => {
     // Do something with the response
  });

Please view the API reference for details and more examples.

Requirements

A Promises/A+ compliant promise implementation must be available globally.

Consuming packages using Browserify must have the Babelify transform, and the ES2015 preset available.

Installation

Node.js via npm

$ npm install --save drf-paginator

SystemJS via jspm

$ jspm install npm:drf-paginator

Scripts

Install dependencies

$ npm install

Run the test suite, generate coverage reports, and lint the source

$ npm test

Run linter

$ npm run jshint

Run unit tests

$ npm run unit

Run the test suite, and generate coverage reports

$ npm run cover

Publish coverage report

$ npm run coveralls

License

Copyright © 2016 Yola. Released under the MIT Expat License.