// This is the same hashing code that the server uses
var stringify = require("json-stable-stringify");

var hashString = function hashString(s) {
  var hash = 0,
      i,
      chr;

  for (i = 0; i < s.length; i++) {
    chr = s.charCodeAt(i);
    hash = (hash << 5) - hash + chr;
    hash |= 0;
  }

  return hash;
};

export default (function (o) {
  return hashString(stringify(o));
});