New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

koa-pagination

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-pagination - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

.babelrc

9

CHANGELOG.md
# Changelog
## [v2.0.0](https://github.com/seegno/koa-pagination/tree/v2.0.0) (2016-05-18)
[Full Changelog](https://github.com/seegno/koa-pagination/compare/v1.1.1...v2.0.0)
**Merged pull requests:**
- Add asterisk support [\#32](https://github.com/seegno/koa-pagination/pull/32) ([nunofgs](https://github.com/nunofgs))
- Refactor to es6 standards [\#31](https://github.com/seegno/koa-pagination/pull/31) ([nunofgs](https://github.com/nunofgs))
- Update dependencies [\#30](https://github.com/seegno/koa-pagination/pull/30) ([nunofgs](https://github.com/nunofgs))
## [v1.1.1](https://github.com/seegno/koa-pagination/tree/v1.1.1) (2016-05-04)

@@ -4,0 +13,0 @@ [Full Changelog](https://github.com/seegno/koa-pagination/compare/v1.1.0...v1.1.1)

55

package.json
{
"name": "koa-pagination",
"version": "1.1.1",
"version": "2.0.0",
"description": "Koa Pagination",
"license": "MIT",
"author": "Seegno",
"main": "index.js",
"main": "dist/src",
"repository": "git@github.com:seegno/koa-pagination",
"scripts": {
"changelog": "github_changelog_generator --no-issues --header-label='# Changelog' --future-release=v$npm_config_future_release && sed -i '' -e :a -e '$d;N;2,4ba' -e 'P;D' CHANGELOG.md",
"test": "NODE_ENV=test ./node_modules/.bin/mocha --harmony-generators --recursive test",
"version": "npm run changelog --future-release=$npm_package_version && git add -A CHANGELOG.md"
"lint": "eslint src test && jscs src test",
"prepublish": "npm run transpile",
"test": "NODE_ENV=test mocha $npm_package_options_mocha",
"transpile": "rm -rf dist/* && babel src --out-dir dist/src",
"version": "npm run changelog --future-release=$npm_package_version && npm run transpile && git add -A CHANGELOG.md dist"
},
"dependencies": {
"debug": "2.1.0",
"debug": "2.2.0",
"http-content-range-format": "1.0.0",
"is-safe-integer": "^1.0.1",
"lodash": "2.4.1",
"range-specifier-parser": "0.1.0",
"is-safe-integer": "1.0.1",
"range-specifier-parser": "v1.0.0",
"standard-http-error": "2.0.0",

@@ -24,18 +26,29 @@ "util": "0.10.3"

"devDependencies": {
"co-mocha": "1.0.2",
"co-supertest": "0.0.7",
"github-changes": "0.0.16",
"jshint": "2.5.10",
"koa": "0.13.0",
"methods": "1.1.0",
"mocha": "2.0.1",
"path": "0.4.9",
"precommit-hook": "1.0.7",
"babel-cli": "^6.8.0",
"babel-eslint": "^6.0.4",
"babel-preset-es2015-node4": "^2.1.0",
"babel-register": "^6.8.0",
"co-mocha": "^1.1.2",
"co-supertest": "^0.0.10",
"eslint": "^2.10.2",
"eslint-config-seegno": "^4.0.0",
"eslint-plugin-babel": "^3.2.0",
"eslint-plugin-sort-class-members": "^1.0.1",
"jscs": "^2.11.0",
"jscs-config-seegno": "^2.0.0",
"koa": "^1.2.0",
"mocha": "^2.4.5",
"precommit-hook": "^3.0.0",
"should": "^8.3.1",
"supertest": "0.15.0",
"test": "0.6.0"
"supertest": "^1.2.0"
},
"engines": {
"node": ">= v0.11.13"
}
"node": ">= 4.0.0"
},
"options": {
"mocha": "--compilers js:babel-register --recursive --require co-mocha --require should"
},
"pre-commit": [
"lint"
]
}

@@ -34,6 +34,6 @@ # Koa Pagination

```js
var koa = require('koa');
var paginate = require('koa-pagination');
import koa from 'koa';
import paginate from 'koa-pagination';
var app = koa();
const app = koa();

@@ -40,0 +40,0 @@ app.get('/', paginate(), function *() {

@@ -6,4 +6,4 @@

var MalformedRangeError = require('../../errors/malformed-range-error');
var StandardHttpError = require('standard-http-error');
import MalformedRangeError from '../../src/errors/malformed-range-error';
import StandardHttpError from 'standard-http-error';

@@ -14,4 +14,4 @@ /**

describe('MalformedRangeError', function() {
it('should inherit from `StandardHttpError`', function() {
describe('MalformedRangeError', () => {
it('should inherit from `StandardHttpError`', () => {
const error = new MalformedRangeError();

@@ -22,3 +22,3 @@

it('should have a default `code`', function() {
it('should have a default `code`', () => {
const error = new MalformedRangeError();

@@ -29,3 +29,3 @@

it('should have a default message', function() {
it('should have a default message', () => {
const error = new MalformedRangeError();

@@ -32,0 +32,0 @@

@@ -6,4 +6,4 @@

var RangeNotSatisfiableError = require('../../errors/range-not-satisfiable-error');
var StandardHttpError = require('standard-http-error');
import RangeNotSatisfiableError from '../../src/errors/range-not-satisfiable-error';
import StandardHttpError from 'standard-http-error';

@@ -14,4 +14,4 @@ /**

describe('RangeNotSatisfiableError', function() {
it('should inherit from `StandardHttpError`', function() {
describe('RangeNotSatisfiableError', () => {
it('should inherit from `StandardHttpError`', () => {
const error = new RangeNotSatisfiableError();

@@ -22,3 +22,3 @@

it('should have a default `code`', function() {
it('should have a default `code`', () => {
const error = new RangeNotSatisfiableError();

@@ -29,3 +29,3 @@

it('should have a default message', function() {
it('should have a default message', () => {
const error = new RangeNotSatisfiableError();

@@ -32,0 +32,0 @@

@@ -6,6 +6,5 @@

var koa = require('koa');
var paginate = require('../');
var request = require('./request')();
var util = require('util');
import koa from 'koa';
import paginate from '../src';
import request from './request';

@@ -16,5 +15,5 @@ /**

describe('paginate', function() {
describe('paginate', () => {
it('should return 200 if no `Range` header is provided', function *() {
var app = koa();
const app = koa();

@@ -34,3 +33,3 @@ app.use(paginate());

it('should return 206 if a valid `Range` header is provided', function *() {
var app = koa();
const app = koa();

@@ -47,3 +46,3 @@ app.use(paginate());

it('should use the default values', function *() {
var app = koa();
const app = koa();

@@ -59,3 +58,3 @@ app.use(paginate());

it('should accept a `maximum` option', function *() {
var app = koa();
const app = koa();

@@ -70,4 +69,4 @@ app.use(paginate({ maximum: 3 }));

it('should give and error if `maximum` is not a number', function *() {
var app = koa();
it('should return 500 if `maximum` is not a number', function *() {
const app = koa();

@@ -82,4 +81,4 @@ app.use(paginate({ maximum: 'invalid' }));

it('should give and error if `maximum` is 0', function *() {
var app = koa();
it('should return 500 if `maximum` is 0', function *() {
const app = koa();

@@ -94,4 +93,4 @@ app.use(paginate({ maximum: 0 }));

it('should give and error if `maximum` is lower than 0', function *() {
var app = koa();
it('should return 500 if `maximum` is lower than 0', function *() {
const app = koa();

@@ -106,4 +105,4 @@ app.use(paginate({ maximum: -1 }));

it('should give and error if `maximum` is not a safe integer', function *() {
var app = koa();
it('should return 500 if `maximum` is not a safe integer', function *() {
const app = koa();

@@ -119,3 +118,3 @@ app.use(paginate({ maximum: 9007199254740993 }));

it('should accept a `Range` header', function *() {
var app = koa();
const app = koa();

@@ -131,4 +130,4 @@ app.use(paginate());

it('should give an error if the `Range` is malformed', function *() {
var app = koa();
it('should return 412 if the `Range` is malformed', function *() {
const app = koa();

@@ -144,4 +143,4 @@ app.use(paginate());

it('should give an error if the `Range` is invalid', function *() {
var app = koa();
it('should return 416 if the `Range` is invalid', function *() {
const app = koa();

@@ -157,4 +156,4 @@ app.use(paginate());

it('should give and error if `first position` value is higher than `length`', function *() {
var app = koa();
it('should return 416 if `first position` value is higher than `length`', function *() {
const app = koa();

@@ -174,4 +173,4 @@ app.use(paginate());

it('should give and error if `first position` and `last position` have equal values and are equal to `length`', function *() {
var app = koa();
it('should return 416 if `first position` and `last position` have equal values and are equal to `length`', function *() {
const app = koa();

@@ -191,4 +190,4 @@ app.use(paginate());

it('should give and error if `first position` and `last position` have equal values and are higher than `length`', function *() {
var app = koa();
it('should return 416 if `first position` and `last position` have equal values and are higher than `length`', function *() {
const app = koa();

@@ -208,4 +207,4 @@ app.use(paginate());

it('should give and error if `first position` is not a safe integer', function *() {
var app = koa();
it('should return 416 if `first position` is not a safe integer', function *() {
const app = koa();

@@ -221,4 +220,4 @@ app.use(paginate());

it('should give and error if `last position` is not a safe integer', function *() {
var app = koa();
it('should return 416 if `last position` is not a safe integer', function *() {
const app = koa();

@@ -234,4 +233,32 @@ app.use(paginate());

it('should return 206 if `last position` is `*`', function *() {
const app = koa();
app.use(paginate());
yield request(app.listen())
.get('/')
.set('Range', 'items=0-*')
.expect(206)
.end();
});
it('should return the `length` if `last position` is `*`', function *() {
const app = koa();
app.use(paginate());
app.use(function *() {
this.pagination.length = 20;
});
yield request(app.listen())
.get('/')
.set('Range', 'items=0-*')
.expect('Content-Range', 'items 0-19/20')
.end();
});
it('should not allow `last position` value to be higher than `length`', function *() {
var app = koa();
const app = koa();

@@ -252,3 +279,3 @@ app.use(paginate());

it('should not allow `last position` to be equal to `length`', function *() {
var app = koa();
const app = koa();

@@ -269,3 +296,3 @@ app.use(paginate());

it('should not allow `last position` value to be higher than `maximum`', function *() {
var app = koa();
const app = koa();

@@ -282,6 +309,6 @@ app.use(paginate({ maximum: 3 }));

it('should use the diference between `last position` and `first position`, plus one, as `limit`', function *() {
var app = koa();
const app = koa();
var lastPosition = 6;
var firstPosition = 2;
const lastPosition = 6;
const firstPosition = 2;

@@ -296,3 +323,3 @@ app.use(paginate());

.get('/')
.set('Range', util.format('items=%s-%s', firstPosition, lastPosition))
.set('Range', `items=${firstPosition}-${lastPosition}`)
.end();

@@ -302,4 +329,4 @@ });

it('should use the `first position` as `offset`', function *() {
var app = koa();
var firstPosition = 2;
const app = koa();
const firstPosition = 2;

@@ -314,3 +341,3 @@ app.use(paginate());

.get('/')
.set('Range', util.format('items=%s-5', firstPosition))
.set('Range', `items=${firstPosition}-5`)
.end();

@@ -320,3 +347,3 @@ });

it('should expose the given `range-unit`', function *() {
var app = koa();
const app = koa();

@@ -337,3 +364,3 @@ app.use(paginate({ unit: 'bytes' }));

it('should set the `byte-range-spec` to `*` if length is 0', function *() {
var app = koa();
const app = koa();

@@ -340,0 +367,0 @@ app.use(paginate({ unit: 'bytes' }));

@@ -6,6 +6,4 @@

var Test = require('co-supertest').Test;
var http = require('http');
var join = require('path').join;
var methods = require('methods');
import { Test } from 'co-supertest';
import { createServer, METHODS as methods } from 'http';

@@ -16,21 +14,20 @@ /**

module.exports = function(prefix) {
return function(app) {
if ('function' === typeof app) {
app = http.createServer(app);
}
export default app => {
if (typeof app === 'function') {
app = createServer(app);
}
var obj = {};
const obj = {};
methods.forEach(function(method) {
obj[method] = function(url) {
return new Test(app, method, join(prefix || '/', url));
};
// Monkey-patch all http methods (GET, PATCH, POST, etc.).
methods
.map(method => method.toLowerCase())
.forEach(method => {
obj[method] = url => new Test(app, method, url);
});
// Support previous use of del
obj.del = obj['delete'];
// Support previous use of del.
obj.del = obj['delete'];
return obj;
};
return obj;
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc