<commit_before>declare module "tree-surgeon" {

    export interface NodeRelation {
        Parent:any;
        Child:any;
        Kind:any;
    };

    export interface DecomposedTree {
        Root:any;
        Nodes:any;
        Relations:Array<NodeRelation>;
    };

    export function decompose(obj:any):DecomposedTree;
}
<commit_msg>Added typings for chain functions<commit_after>declare module "tree-surgeon" {

    export type RelationPredicate = (NodeRelation)=>boolean;
    export type RelationSelector = NodeRelation | string | RelationPredicate;

    /** NodeRelation can be decorated to contain any other properties */
    export interface NodeRelation /*extends any*/ {
        Parent?:any;
        Child?:any;
        Kind?:any;
        [index: string]: any;
    }

    export function decompose(obj:any):DecomposedTree;

    export interface DecomposedTree extends CallBoundObject {
        Root:number;
        RootArray:boolean;
        Nodes:any;
        Relations:Array<NodeRelation>;
    }

    interface CallBoundObject {
        // Functions that compose trees (can't be chained)
        compose():any;
        render(renderNodeFunc:(node:any, path:[string], id:string)=>any, renderKindFunc:(kind:string, path:[string])=>string):any;
        harvest(kind:RelationSelector,keySelector:(any)=>any):any;
        gatherByKind(kind:RelationSelector):[any];
        gatherByNode(nodePredicate:(any)=>boolean):[any];

        // Functions that manipulate the relational model (can be chained)
        normalise():DecomposedTree;
        flipRelationship(newChildKind:string, newParentKind:string, newParentHashFunc:(any)=>any):DecomposedTree;
        reverseByRelation(relationFilter:RelationSelector, groupPredicate:(r:NodeRelation)=>any):DecomposedTree;
        removeEmptyNodes():DecomposedTree;
        prune(kind:RelationSelector):DecomposedTree;
        pruneAfter(kind:RelationSelector):DecomposedTree;
        pruneAllBut(kinds:[string]):DecomposedTree;
        chopNodesByIds(ids:[string]):DecomposedTree;
        chop(filter:(node:any, id:number)=>boolean):DecomposedTree;
        chopAfter(filter:(node:any, id:number)=>boolean):DecomposedTree;
        chopChildless(filter:(node:any, id:number)=>boolean):DecomposedTree;
        chopByKind(kind:RelationSelector, filter:(node:any, id:number)=>boolean):DecomposedTree;
        chopNodesByData(dataKind:RelationSelector, targetKind:RelationSelector, victimKind:RelationSelector, selectorFunc:(node:any)=>boolean, victimFunc:(node:any)=>boolean):DecomposedTree;
        chopPathsByData(dataKind:RelationSelector, targetKind:RelationSelector, victimKind:RelationSelector, selectorFunc:(node:any)=>boolean, victimFunc:(node:any)=>boolean):DecomposedTree;
        mergeUpByKind(kind:RelationSelector):DecomposedTree;
        mergeUpByNode(nodePredicate:(any)=>boolean):DecomposedTree;
        mergeDownByKind(kind:RelationSelector):DecomposedTree;
        mergeDownByNode(nodePredicate:(any)=>boolean):DecomposedTree;
        fuseByNode(nodePredFunc:(any)=>boolean, pickForParentFunc:(any)=>any, pickForChildFunc:(any)=>any):DecomposedTree;
        fuseByKind(kind:RelationSelector, pickForParentFunc:(any)=>any, pickForChildFunc:(any)=>any):DecomposedTree;
        reduce(kind:string,propertyName:string):DecomposedTree;
        editByKind(kind:RelationSelector, filterFunc:(any)=>any):DecomposedTree;
        forEachByKind(kind:RelationSelector, actionFunc:(any)=>void):DecomposedTree;
        reverseTree(kind:string):DecomposedTree;

        // Special selector functions (can't be chained)
        getPathOf(nodeId:number):[string];
        getNode(nodeId:number):any;
        getChildrenOf(parentId:number):[number];
        getChildrenByKindOf(parentId:number, kind:RelationSelector):[number];
        parentIdOf(childId:number):number;
    }

}

{'fraction_non_alphanumeric': 0.11645764013309444, 'fraction_numerical': 0.0, 'mean_word_length': 4.224598930481283, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6493619', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1115, 'n_words': 152}