<commit_before>var bindings = require('bindings')('storm-replay');

module.exports = {
    extractFile: function(Archive, File) {
        // 'replay.attributes.events',
        // 'replay.details',
        // 'replay.game.events',
        // 'replay.initData',
        // 'replay.load.info',
        // 'replay.message.events',
        // 'replay.smartcam.events',
        // 'replay.sync.events'
        var ret = bindings.extractFile(Archive, File);
        var obj = {
            err: (ret.length === undefined),
            content: {
                data: ret,
                size: ret.length
            }
        };
        return obj;
    },

    getHeader: function(Archive) {
        var ret = bindings.getHeader(Archive);
        var obj = {
            err: (ret.length === undefined),
            header: {
                data: ret,
                size: ret.length
            },
            content: {
                data: ret.slice(16, 16 + ret.readUInt32LE(12)),
                size: ret.readUInt32LE(12)
            }
        };
        return obj;
    }
};

// var data = bindings.extractFile('replays/garden-of-terror.StormReplay', 'replay.game.events');
// var header = bindings.getHeader('replays/garden-of-terror.StormReplay');<commit_msg>return objects directly<commit_after>var bindings = require('bindings')('storm-replay');

module.exports = {
    extractFile: function(Archive, File) {
        // 'replay.attributes.events',
        // 'replay.details',
        // 'replay.game.events',
        // 'replay.initData',
        // 'replay.load.info',
        // 'replay.message.events',
        // 'replay.smartcam.events',
        // 'replay.sync.events'
        var ret = bindings.extractFile(Archive, File);
        return {
            err: (ret.length === undefined),
            content: {
                data: ret,
                size: ret.length
            }
        };
    },

    getHeader: function(Archive) {
        var ret = bindings.getHeader(Archive);
        return {
            err: (ret.length === undefined),
            header: {
                data: ret,
                size: ret.length
            },
            content: {
                data: ret.slice(16, 16 + ret.readUInt32LE(12)),
                size: ret.readUInt32LE(12)
            }
        };
    }
};
{'fraction_non_alphanumeric': 0.14334911752044768, 'fraction_numerical': 0.010331467929401636, 'mean_word_length': 1.4749733759318424, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '578539', 'n_tokens_mistral': 706, 'n_tokens_neox': 657, 'n_words': 112}