Last active
June 2, 2020 02:31
-
-
Save sonbyungjun/04861189375d374958da889f58a29a54 to your computer and use it in GitHub Desktop.
TypeScript(Javascript) Paginate Calculation Function (타입스크립트(자바스크립트) 페이지네이션 계산 함수)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const paginate = (array: any, index: any, size: any) => { | |
// transform values | |
index = Math.abs(parseInt(index)); | |
index = index > 0 ? index - 1 : index; | |
size = parseInt(size); | |
size = size < 1 ? 1 : size; | |
// filter | |
return [ | |
...array.filter((value: any, n: any) => { | |
return n >= index * size && n < (index + 1) * size; | |
}), | |
]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
페이지 계산 함수 감사합니다!