pagination-generator
Advanced tools
Comparing version 1.0.2 to 1.0.3
22
index.js
@@ -19,5 +19,5 @@ "use strict"; | ||
*/ | ||
module.exports = function pagination(current, total, limit) { | ||
export default function paginationGenerator(current, total, limit) { | ||
current = Math.min(total, Math.max(1, current)); | ||
var first = { | ||
let first = { | ||
type: "nav", | ||
@@ -28,3 +28,3 @@ name: "first", | ||
}; | ||
var last = { | ||
let last = { | ||
type: "nav", | ||
@@ -35,3 +35,3 @@ name: "last", | ||
}; | ||
var prev = { | ||
let prev = { | ||
type: "nav", | ||
@@ -42,3 +42,3 @@ name: "prev", | ||
}; | ||
var next = { | ||
let next = { | ||
type: "nav", | ||
@@ -61,4 +61,4 @@ name: "next", | ||
} | ||
var start = 1, end = total; | ||
var before = [], after = []; | ||
let start = 1, end = total; | ||
let before = [], after = []; | ||
if (total > limit) { | ||
@@ -68,3 +68,3 @@ before = [first, prev]; | ||
limit -= 4; | ||
var half = Math.floor(limit / 2); | ||
let half = Math.floor(limit / 2); | ||
if (current <= half) { | ||
@@ -79,4 +79,4 @@ end = limit; | ||
} | ||
var pages = []; | ||
for (var i = start; i <= end; i++) { | ||
let pages = []; | ||
for (let i = start; i <= end; i++) { | ||
pages.push({ | ||
@@ -90,2 +90,2 @@ type: "num", | ||
return before.concat(pages, after); | ||
}; | ||
} |
{ | ||
"name": "pagination-generator", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "pagination generator", | ||
"main": "index.js", | ||
"main": "index.umd.js", | ||
"jsnext:main": "index.js", | ||
"scripts": { | ||
"test": "mocha test.js" | ||
"test": "mocha test.js", | ||
"build": "rollup -c rollup.config.js" | ||
}, | ||
@@ -16,4 +18,8 @@ "keywords": [ | ||
"devDependencies": { | ||
"babel-core": "^6.7.4", | ||
"babel-preset-es2015-rollup": "^1.1.1", | ||
"chai": "^3.5.0", | ||
"mocha": "^2.4.5" | ||
"mocha": "^2.4.5", | ||
"rollup": "^0.25.6", | ||
"rollup-plugin-babel": "^2.4.0" | ||
}, | ||
@@ -20,0 +26,0 @@ "dependencies": {}, |
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
14921
8
288
6