index.js
function buildTree(memo, data) {
        if (data.level === memo.level) {
            memo.pointer.tree.push(data);
        } else if (data.level > memo.level) {
            var up = memo.pointer;
            memo.pointer = memo.pointer.tree[
                memo.pointer.tree.length - 1];
                memo.pointer.tree.push(data);
                memo.pointer.up = up;
                memo.level = data.level;
        } else if (data.level < memo.level) {
            // the jump up in the stack may be by more than one, so ascend
            // until we're at the right level.
            while (data.level <= memo.pointer.level && memo.pointer.up) {
                memo.pointer = memo.pointer.up;
            }
            memo.pointer.tree.push(data);
            memo.level = data.level;
        }
        return memo;
    }
function buildTree(memo, data) {
        if (data.level === memo.level) {
            memo.pointer.tree.push(data);
        } else if (data.level > memo.level) {
            var up = memo.pointer;
            memo.pointer = memo.pointer.tree[
                memo.pointer.tree.length - 1];
                memo.pointer.tree.push(data);
                memo.pointer.up = up;
                memo.level = data.level;
        } else if (data.level < memo.level) {
            // the jump up in the stack may be by more than one, so ascend
            // until we're at the right level.
            while (data.level <= memo.pointer.level && memo.pointer.up) {
                memo.pointer = memo.pointer.up;
            }
            memo.pointer.tree.push(data);
            memo.level = data.level;
        }
        return memo;
    }
function buildTree ( memo , data ) { if ( data . level === memo . level ) { memo . pointer . tree . push ( data ) ; } else if ( data . level > memo . level ) { var up = memo . pointer ; memo . pointer = memo . pointer . tree [ memo . pointer . tree . length - 1 ] ; memo . pointer . tree . push ( data ) ; memo . pointer . up = up ; memo . level = data . level ; } else if ( data . level < memo . level ) { // the jump up in the stack may be by more than one, so ascend // until we're at the right level. while ( data . level <= memo . pointer . level && memo . pointer . up ) { memo . pointer = memo . pointer . up ; } memo . pointer . tree . push ( data ) ; memo . level = data . level ; } return memo ; }
the basic trick of this module is turning the suggested tree structure of a GEDCOM file into a tree in JSON. This reduction does that. The only real trick is the `.up` member of objects that points to a level up in the structure. This we have to censor before JSON.stringify since it creates circular references.
the basic trick of this module is turning the suggested tree structure of a GEDCOM file into a tree in JSON . This reduction does that . The only real trick is the . up member of objects that points to a level up in the structure . This we have to censor before JSON . stringify since it creates circular references .