pagination-generator
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -42,3 +42,3 @@ "use strict"; | ||
name: "next", | ||
value: Math.min(current, current + 1), | ||
value: Math.min(current + 1, total), | ||
disabled: current === total, | ||
@@ -45,0 +45,0 @@ }; |
{ | ||
"name": "pagination-generator", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "pagination generator", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -22,5 +22,5 @@ # pagination generator | ||
{ type: 'num', name: 6, value: 6, current: false }, | ||
{ type: 'nav', name: 'next', value: 4, disabled: false }, | ||
{ type: 'nav', name: 'next', value: 5, disabled: false }, | ||
{ type: 'nav', name: 'last', value: 1000, disabled: false } ] | ||
*/ | ||
``` |
17
test.js
@@ -25,3 +25,3 @@ "use strict"; | ||
name: "next", | ||
value: 1, | ||
value: 2, | ||
disabled: false, | ||
@@ -65,5 +65,9 @@ }); | ||
const e1 = ["first", "prev", 1, 2, 3, 4, 5, "next", "last"]; | ||
const v1 = [1, 1, 1, 2, 3, 4, 5, 3, 10]; | ||
expect(getNames( | ||
pagination(2, 10, 9) | ||
)).to.be.eql(e1); | ||
expect(getValues( | ||
pagination(2, 10, 9) | ||
)).to.be.eql(v1); | ||
@@ -75,5 +79,9 @@ expect(getCurrentValue( | ||
const e2 = ["first", "prev", 3, 4, 5, 6, 7, "next", "last"]; | ||
const v2 = [1, 4, 3, 4, 5, 6, 7, 6, 10]; | ||
expect(getNames( | ||
pagination(5, 10, 9) | ||
)).to.be.eql(e2); | ||
expect(getValues( | ||
pagination(5, 10, 9) | ||
)).to.be.eql(v2); | ||
@@ -85,5 +93,9 @@ expect(getCurrentValue( | ||
const e3 = ["first", "prev", 6, 7, 8, 9, 10, "next", "last"]; | ||
const v3 = [1, 8, 6, 7, 8, 9, 10, 10, 10]; | ||
expect(getNames( | ||
pagination(9, 10, 9) | ||
)).to.be.eql(e3); | ||
expect(getValues( | ||
pagination(9, 10, 9) | ||
)).to.be.eql(v3); | ||
@@ -98,2 +110,5 @@ expect(getCurrentValue( | ||
} | ||
function getValues(ary) { | ||
return ary.map(item => item.value); | ||
} | ||
function getCurrentValue(ary) { | ||
@@ -100,0 +115,0 @@ return ary.filter(item => item.current)[0].value; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7441
185