// Generated by IcedCoffeeScript 1.7.1-c
(function() {
  var e, mp, pp, set_opt, set_opts, _opts;

  try {
    mp = require('msgpack');
  } catch (_error) {
    e = _error;
  }

  if (mp == null) {
    try {
      pp = require('purepack');
      mp = pp;
    } catch (_error) {
      e = _error;
    }
  }

  if ((mp == null) && (pp == null)) {
    throw new Error("Need either msgpack or purepack to run");
  }

  _opts = {};

  exports.set_opt = set_opt = function(k, v) {
    return _opts[k] = v;
  };

  exports.set_opts = set_opts = function(o) {
    return _opts = o;
  };

  exports.use_byte_arrays = function() {
    var err;
    if (pp == null) {
      try {
        return mp = pp = require('purepack');
      } catch (_error) {
        err = _error;
        throw new Error("Cannot use_byte_arrays without purepack!");
      }
    }
  };

  exports.pack = function(b) {
    return mp.pack(b);
  };

  exports.unpack = function(b) {
    var dat, err;
    err = dat = null;
    try {
      dat = mp.unpack(b);
    } catch (_error) {
      err = _error;
    }
    return [err, dat];
  };

}).call(this);
