{"size": 525, "ext": "js", "max_stars_repo_path": "src/Providers/Social/Message.js", "max_stars_repo_name": "ickerio/Krunky", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Providers/Social/Message.js", "max_issues_repo_name": "ickerio/Krunky", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Providers/Social/Message.js", "max_forks_repo_name": "ickerio/Krunky", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.8260869565, "max_line_length": 51, "alphanum_fraction": 0.5542857143}
const { encode, decode } = require('msgpack-lite');

class Message {
    static encode(array) {
        const encBuff = encode(array);
        return this.toArrayBuffer(encBuff);
    }

    static decode(data) {
        return decode(new Uint8Array(data));
    }

    static toArrayBuffer(buf) {
        var ab = new ArrayBuffer(buf.length + 2);
        var view = new Uint8Array(ab);
        for (var i = 0; i < buf.length; ++i) {
            view[i] = buf[i];
        }
        return ab;
    }
}

module.exports = Message;