util.js 588 B

123456789101112131415161718192021222324
  1. // Generated by IcedCoffeeScript 1.7.1-f
  2. (function() {
  3. var constants, createHash, json_stringify_sorted, strip;
  4. json_stringify_sorted = require('iced-utils').util.json_stringify_sorted;
  5. createHash = require('crypto').createHash;
  6. constants = require('./constants').constants;
  7. exports.strip = strip = function(x) {
  8. var m;
  9. if ((m = x.match(/^(\s*)(.*?)(\s*)$/))) {
  10. return m[2];
  11. } else {
  12. return x;
  13. }
  14. };
  15. exports.hash_json = function(x) {
  16. return createHash('SHA512').update(strip(json_stringify_sorted(x))).digest('hex');
  17. };
  18. }).call(this);