<commit_before>module AST from "AST.js";

import { Parser } from "Parser.js";
import { Scanner } from "Scanner.js";

export { Parser, Scanner, AST };

export function parseModule(input, options) {

    return new Parser(input, options).Module();
}

export function parseScript(input, options) {

    return new Parser(input, options).Script();
}

export function forEachChild(node, fn) {

    var keys = Object.keys(node), val, i, j;
    
    for (i = 0; i < keys.length; ++i) {
    
        // Don't iterate over backlink to parent
        if (keys[i] === "parentNode")
            continue;
            
        val = node[keys[i]];
        
        // Skip non-objects
        if (val !== Object(val)) 
            continue;
        
        if (typeof val.type === "string") {
        
            // Nodes have a "type" property
            fn(val);
        
        } else {
        
            // Iterate arrays
            for (j = 0; j < (val.length >>> 0); ++j)
                if (val[j] && typeof val[j].type === "string")
                    fn(val[j]);
        }
    }
}

<commit_msg>Remove exported forEachNode (now a method of AST.Node).<commit_after>module AST from "AST.js";

import { Parser } from "Parser.js";
import { Scanner } from "Scanner.js";

export { Parser, Scanner, AST };

export function parseModule(input, options) {

    return new Parser(input, options).Module();
}

export function parseScript(input, options) {

    return new Parser(input, options).Script();
}

{'fraction_non_alphanumeric': 0.13875917278185457, 'fraction_numerical': 0.0020013342228152103, 'mean_word_length': 2.0864197530864197, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '4170713', 'n_tokens_mistral': 471, 'n_tokens_neox': 451, 'n_words': 131}