orderBy.d.ts 859 B

123456789101112131415161718192021222324252627282930
  1. import { XEUtilsMethods } from '../xe-utils'
  2. interface OrderBySortConfs<T, C> {
  3. field?: string | ((this: C, item: T, index: number, list: T[]) => any) | null;
  4. order?: 'order' | 'desc' | null;
  5. }
  6. export type OrderByFieldConfs<T, C> = null | string | OrderBySortConfs<T, C> | (string | OrderBySortConfs<T, C>)[] | ((this: C, item: T, index: number, list: T[]) => any);
  7. /**
  8. * 将数组进行排序
  9. * @param array 数组
  10. * @param fieldConfs 排序规则
  11. * @param context 上下文
  12. */
  13. export declare function orderBy<T, C>(array: T[], fieldConfs: OrderByFieldConfs<T, C>, context?: C): T[];
  14. declare module '../xe-utils' {
  15. interface XEUtilsMethods {
  16. /**
  17. * 将数组进行排序
  18. * @param array 数组
  19. * @param fieldConfs 排序规则
  20. * @param context 上下文
  21. */
  22. orderBy: typeof orderBy;
  23. }
  24. }
  25. export default orderBy