Skip to content

Commit bc750d7

Browse files
committed
Fix bug on bundle
1 parent bbc2eef commit bc750d7

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

__tests__/pagesBadges.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ Deno.test("Should work with just 5 pages", async () => {
1515
assertEquals(output, expected);
1616
});
1717

18+
Deno.test("Should work with 9 pages", async () => {
19+
const input = { currentPage: 1, pages: 9 };
20+
const output = pagesBadges(input);
21+
const expected = [1, 2, 3, 4, null, 9];
22+
assertEquals(output, expected);
23+
});
24+
1825
Deno.test("Should work with pages bigger than 5", async () => {
1926
const input = { currentPage: 14, pages: 20 };
2027
const output = pagesBadges(input);

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ export default function pagesBadges({ currentPage, pages, numBadges = 5 }) {
33

44
// Without separators case
55
// ex: [1, 2, 3, 4, 5]
6-
if (pages <= numBadges) return [...Array(pages)].map((v, i) => i + 1);
6+
if (pages <= numBadges) return Array.from({ length: pages }).map((v, i) => i + 1);
77

8-
const sideBadges = [...Array(numBadges - 1)];
8+
const sideBadges = Array.from({ length: numBadges - 1 });
99

1010
// With a separator at the end case
1111
// ex: [1, 2, 3, 4, null, 49]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-paging",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Paging badges generator",
55
"source": "index.js",
66
"main": "dist/index.js",

0 commit comments

Comments
 (0)