-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Intro
Hey there!
I just went through your lib and src folders and read your scripts. It looks like you don't check for the result of parseInput for the currentPage and the perPage variables. This will then make the library not work properly and could cause issues.
I know that the people using your package could simply check the values before they submit them to your library however I feel like it still needs to make its own place into here.
Steps to reproduce
Step 1
Create a JS file (let's call it index.js) and copy-paste the following code :
const paginate = require('paginate-array');
const array = [1, 2, 3, 4, 5, 6];
console.log(paginate(array, NaN));or
const paginate = require('paginate-array');
const array = [1, 2, 3, 4, 5, 6];
console.log(paginate(array, 1, NaN));Step 2
Type node index.js and observe the result
Results
Expected
Uncaught TypeError: page is not a number
or
Uncaught TypeError: numItems is not a number
Received
{ currentPage: NaN,
perPage: 10,
total: 6,
totalPages: 1,
data: []
}or
{ currentPage: 1,
perPage: NaN,
total: 6,
totalPages: NaN,
data: []
}Metadata
Metadata
Assignees
Labels
No labels