Skip to content

Instantly share code, notes, and snippets.

@sonbyungjun
Last active June 2, 2020 02:31
Show Gist options
  • Save sonbyungjun/04861189375d374958da889f58a29a54 to your computer and use it in GitHub Desktop.
Save sonbyungjun/04861189375d374958da889f58a29a54 to your computer and use it in GitHub Desktop.
TypeScript(Javascript) Paginate Calculation Function (타입스크립트(자바스크립트) 페이지네이션 계산 함수)
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;
}),
];
};
@hmmhmmhm
Copy link

hmmhmmhm commented Jun 2, 2020

페이지 계산 함수 감사합니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment