dify-components
Version:
This is a modern component library template based on Turborepo+Vue 3.5+TypeScript.
16 lines (14 loc) • 316 B
text/typescript
/**
* 数组去重
*/
export const unique = <T>(arr: T[]): T[] => {
return Array.from(new Set(arr));
};
/**
* 数组分块
*/
export const chunk = <T>(arr: T[], size: number): T[][] => {
return Array.from({ length: Math.ceil(arr.length / size) }, (_, i) =>
arr.slice(i * size, i * size + size),
);
};