type-inference.js
// We use the convention that any property starting with `$` should not be considered a child node.
We use the convention that any property starting with `$` should not be considered a child node.
We use the convention that any property starting with ` $ ` should not be considered a child node .
function children(node) {
    if (node.type === 'ExportSpecifier' && node.local === node.exported) {
        return [node.local]
    }
    var result = [];
    for (var k in node) {
        if (!node.hasOwnProperty(k))
            continue;
        if (k[0] === '$')
            continue;
        var val = node[k];
        if (!val)
            continue;
        if (val && typeof val === "object" && typeof val.type === "string") {
            result.push(val);
        }
        else if (val instanceof Array) {
            for (var i=0; i<val.length; i++) {
                var elm = val[i];
                if (elm && typeof elm === "object" && typeof elm.type === "string") {
                    result.push(elm);
                }
            }
        } 
    }
    return result;
}
function children ( node ) { if ( node . type === 'ExportSpecifier' && node . local === node . exported ) { return [ node . local ] } var result = [ ] ; for ( var k in node ) { if ( ! node . hasOwnProperty ( k ) ) continue ; if ( k [ 0 ] === '$' ) continue ; var val = node [ k ] ; if ( ! val ) continue ; if ( val && typeof val === "object" && typeof val . type === "string" ) { result . push ( val ) ; } else if ( val instanceof Array ) { for ( var i = 0 ; i < val . length ; i ++ ) { var elm = val [ i ] ; if ( elm && typeof elm === "object" && typeof elm . type === "string" ) { result . push ( elm ) ; } } } } return result ; }
We use the convention that any property starting with `$` should not be considered a child node.
We use the convention that any property starting with ` $ ` should not be considered a child node .
// Sometimes the AST is not actually a tree :(