lib/hash.js
function stringify(val) {
  if (typeof val === 'string') return JSON.stringify(val.toLowerCase());

  if (Array.isArray(val)) return '[' + val.map(stringify) + ']';

  if ((typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object' && '' + val === '[object Object]') {
    var str = Object.keys(val).sort().map(function (key) {
      return stringify(key) + ':' + stringify(val[key]);
    }).join(',');

    return '{' + str + '}';
  }

  return JSON.stringify(val);
}
function stringify(val) {
  if (typeof val === 'string') return JSON.stringify(val.toLowerCase());

  if (Array.isArray(val)) return '[' + val.map(stringify) + ']';

  if ((typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object' && '' + val === '[object Object]') {
    var str = Object.keys(val).sort().map(function (key) {
      return stringify(key) + ':' + stringify(val[key]);
    }).join(',');

    return '{' + str + '}';
  }

  return JSON.stringify(val);
}
function stringify ( val ) { if ( typeof val === 'string' ) return JSON . stringify ( val . toLowerCase ( ) ) ; if ( Array . isArray ( val ) ) return '[' + val . map ( stringify ) + ']' ; if ( ( typeof val === 'undefined' ? 'undefined' : _typeof ( val ) ) === 'object' && '' + val === '[object Object]' ) { var str = Object . keys ( val ) . sort ( ) . map ( function ( key ) { return stringify ( key ) + ':' + stringify ( val [ key ] ) ; } ) . join ( ',' ) ; return '{' + str + '}' ; } return JSON . stringify ( val ) ; }
Deterministic JSON.stringify for resource record stuff

Object keys are sorted so strings are always the same independent of
what order properties were added in. Strings are lowercased because
record names, TXT keys, SRV target names, etc. need to be compared
case-insensitively.

@param  {*} val
@return {string}
Deterministic JSON . stringify for resource record stuff