UNPKG

1.12 kBTypeScriptView Raw
1export interface MapTreeOptions {
2 children?: string;
3 mapChildren?: string;
4}
5
6/**
7 * 从树结构中指定方法后的返回值组成的新数组
8 * @param {Object} obj 对象/数组
9 * @param {Function} iterate(item, index, items, path, parent, nodes) 回调
10 * @param {Object} options {children: 'children', mapChildren: 'children}
11 * @param {Object} context 上下文
12 */
13export declare function mapTree<T, U, C>(array: T[], iterate: (this: C, item: T, index: number, items: T[], path: string[], parent: T, nodes: T[]) => U, options?: MapTreeOptions, context?: C): U[];
14export declare function mapTree<U, C>(array: any[], iterate: (this: C, item: any, index: number, items: any[], path: string[], parent: any, nodes: any[]) => U, options?: MapTreeOptions, context?: C): U[];
15export declare function mapTree<U, C>(array: any, iterate: (this: C, item: any, index: number, items: any, path: string[], parent: any, nodes: any) => U, options?: MapTreeOptions, context?: C): U[];
16
17declare module './ctor' {
18 interface XEUtilsMethods {
19 mapTree: typeof mapTree;
20 }
21}
22
23export default mapTree