Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

data-pager

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-pager - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

43

lib/data-pager.js

@@ -96,3 +96,2 @@ /**

}
throw new Error('Cannot set page beyond the last page of this set: ' + value);
},

@@ -128,3 +127,3 @@

return parseInt(pages) + 1;
return parseInt(pages, 10) + 1;
},

@@ -182,16 +181,13 @@

previousPages: function(n) {
var pages = [],
page = this.page,
max = page - n;
var page = this.page,
pages = [];
if (max < 0) {
return [];
}
for (var i = 0; i < n && 1 <= page; i++) {
page = page - 1;
if (max === 0) {
return [1];
}
if (page < 1) {
break;
}
for (var i = 0; i < n; i++) {
pages.push(page - 1 - i);
pages.push(page);
}

@@ -203,3 +199,3 @@

/**
* List n previous pages after this page, excluding the last page
* List n previous pages after this page
*

@@ -210,17 +206,14 @@ * @argument {Number} n Number of pages to list

nextPages: function(n) {
var pages = [],
last = this.last,
var last = this.last,
page = this.page,
max = page + 1;
pages = [];
if (last < max) {
return [];
}
for (var i = 0; i < n; i++) {
page = page + 1;
if (last === max) {
return [last];
}
if (last < page) {
break;
}
for (var i = 0; i < n; i++) {
pages.push(page + 1 + i);
pages.push(page);
}

@@ -227,0 +220,0 @@

{
"name": "data-pager",
"version": "0.0.2",
"version": "0.0.3",
"description": "Abstraction for the fiddly logic associated with paging results",

@@ -25,3 +25,3 @@ "main": "./index.js",

"readmeFilename": "README.md",
"gitHead": "b4086073a14f335939eae4bc5e0202d5f0d05de2"
"gitHead": "5012042590e8425626bb8729e4728be0536089a7"
}

@@ -25,3 +25,3 @@ var Pager = require('../index'),

next: 2,
nextPages: [2, 3],
nextPages: [2, 3, 4],
previousPages: []

@@ -60,3 +60,3 @@ },

nextPages: [],
previousPages: [2, 3],
previousPages: [1, 2, 3],
},

@@ -75,4 +75,4 @@ ];

assert.equal(pager.entriesOnPage, testCase.entries);
assert.deepEqual(pager.nextPages(2), testCase.nextPages);
assert.deepEqual(pager.previousPages(2), testCase.previousPages, 'page: ' + pager.page + ': ' + pager.previousPages(2).toString(', '));
assert.deepEqual(pager.nextPages(4), testCase.nextPages);
assert.deepEqual(pager.previousPages(4), testCase.previousPages);
});

@@ -79,0 +79,0 @@

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