mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
85a7c55fdf
This PR adds support for projects as a first class citizen, and toggling features on in different environments.
23 lines
545 B
TypeScript
23 lines
545 B
TypeScript
export const paginate = (data: any[], limit: number) => {
|
|
let result = [];
|
|
let currentIdx = 0;
|
|
|
|
if (data.length <= currentIdx) {
|
|
return data;
|
|
}
|
|
|
|
while (currentIdx < data.length) {
|
|
if (currentIdx === 0) {
|
|
currentIdx += limit;
|
|
const page = data.slice(0, currentIdx);
|
|
result.push(page);
|
|
} else {
|
|
const page = data.slice(currentIdx, currentIdx + limit);
|
|
currentIdx += limit;
|
|
result.push(page);
|
|
}
|
|
}
|
|
|
|
return result;
|
|
};
|