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

pagination

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pagination - npm Package Compare versions

Comparing version 0.3.7 to 0.3.8

tests/parse_option.js

26

lib/pagination.js

@@ -62,2 +62,3 @@ (function(module) {

var keys, i, len;
/* validate in this.set if needed */
this.options = {

@@ -171,4 +172,27 @@ totalResult : 0,

if(this.options.hasOwnProperty(option)) {
switch(option) {
case 'current':
case 'totalResult':
case 'pageLinks':
case 'rowsPerPage':
value = parseInt(value, 10);
if (isNaN(value)) {
throw new Error('Invalid value for "' + option + '", expected an integer');
}
break;
case 'translator':
if (!(value && value.constructor && value.call && value.apply)) {
throw new Error('Translator must be a function');
}
break;
case 'translationCacheKey':
case 'pageParamName':
case 'prelink':
value = String(value);
break;
}
this.options[option] = value;
this._result = null;
if (this._result) {
this._result = null;
}
}

@@ -175,0 +199,0 @@ },

2

package.json

@@ -14,3 +14,3 @@ {

},
"version": "0.3.7",
"version": "0.3.8",
"scripts": {

@@ -17,0 +17,0 @@ "test": "vows --spec tests/*"

@@ -188,2 +188,65 @@ var assert = require('assert');

},
getPaginationData1 : function() {
var item = new Paginator({
prelink : '/',
pageLinks : 5,
current : 1,
totalResult : 100
});
assert.deepEqual({
prelink : '/',
current : 1,
previous : null,
next : 2,
first : null,
last : 10,
range : [1, 2, 3, 4, 5],
fromResult : 1,
toResult : 10,
totalResult : 100,
pageCount : 10
}, item.getPaginationData());
},
getPaginationData3 : function() {
var item = new Paginator({
prelink : '/',
pageLinks : 5,
current : 3,
totalResult : 100
});
assert.deepEqual({
prelink : '/',
current : 3,
previous : 2,
next : 4,
first : 1,
last : 10,
range : [1, 2, 3, 4, 5],
fromResult : 21,
toResult : 30,
totalResult : 100,
pageCount : 10
}, item.getPaginationData());
},
getPaginationData4 : function() {
var item = new Paginator({
prelink : '/',
pageLinks : 5,
current : 4,
totalResult : 100
});
assert.deepEqual({
prelink : '/',
current : 4,
previous : 3,
next : 5,
first : 1,
last : 10,
range : [2, 3, 4, 5, 6],
fromResult : 31,
toResult : 40,
totalResult : 100,
pageCount : 10
}, item.getPaginationData());
},
testPreparePreLink : function() {

@@ -238,7 +301,8 @@ var item = new Paginator({

});
var test_translator = function() {}
item.set('totalResult', 3000);
item.set('notSupported', 'notfound');
// ugly :-)
item.set('translator', null);
item.set('translator', test_translator);
assert.deepEqual({

@@ -250,3 +314,3 @@ totalResult : 3000,

current : 5,
translator : null,
translator : test_translator,
translationCache : false,

@@ -253,0 +317,0 @@ translationCacheKey: 'en',

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