findTree.d.ts 779 B

1234567891011121314151617181920212223242526272829
  1. interface TerrResult<T = any> {
  2. index: number;
  3. item: T;
  4. path: Array<string>;
  5. items: T[];
  6. parent: T;
  7. nodes: T[];
  8. }
  9. interface FindTreeOptions {
  10. children?: string;
  11. }
  12. /**
  13. * 从树结构中查找匹配第一条数据的键、值、路径
  14. * @param {Object} list 数组
  15. * @param {Function} iterate(item, index, items, path, parent, nodes) 回调
  16. * @param {Object} options {children: 'children'}
  17. * @param {Object} context 上下文
  18. */
  19. export declare function findTree<T, C>(list: T[], iterate: (this: C, item: T, index: number, items: T[], path: string[], parent: T, nodes: T[]) => boolean, options?: FindTreeOptions, context?: C): TerrResult<T>;
  20. declare module './ctor' {
  21. interface XEUtilsMethods {
  22. findTree: typeof findTree;
  23. }
  24. }
  25. export default findTree