findTree.d.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { XEUtilsMethods } from '../xe-utils'
  2. export declare function findTreeIterate(item: any, index: number, items: any[], path: string[], parent: any, nodes: any[]): any;
  3. interface TerrResult {
  4. index: number;
  5. item: any;
  6. path: Array<string>;
  7. items: any[];
  8. parent: any;
  9. nodes: any[];
  10. }
  11. interface FindTreeOptions {
  12. children?: string;
  13. }
  14. /**
  15. * 从树结构中查找匹配第一条数据的键、值、路径
  16. * @param {Object} obj 对象/数组
  17. * @param {Function} iterate(item, index, items, path, parent, nodes) 回调
  18. * @param {Object} options {children: 'children'}
  19. * @param {Object} context 上下文
  20. */
  21. export declare function findTree(array: any[], iterate: typeof findTreeIterate, options?: FindTreeOptions, context?: any): TerrResult;
  22. declare module '../xe-utils' {
  23. interface XEUtilsMethods {
  24. /**
  25. * 从树结构中查找匹配第一条数据的键、值、路径
  26. * @param {Object} obj 对象/数组
  27. * @param {Function} iterate(item, index, items, path, parent, nodes) 回调
  28. * @param {Object} options {children: 'children'}
  29. * @param {Object} context 上下文
  30. */
  31. findTree: typeof findTree;
  32. }
  33. }
  34. export default findTree