Nodejs String from Hex fromHex()

Here you can find the source of fromHex()

Method Source Code

// Method to decode a hex string as text
// '53 65 74 68'.fromHex(); returns 'Seth'
String.prototype.fromHex = function() {
  for (var hex = this.split(' '), i = 0, $ = '', h; h = hex[i]; i++) $ += String.fromCharCode(parseInt(h, 16));
  return $;/*from w  w w . j  a  v  a  2 s  . c o  m*/
};

Related

  1. fromHex()
    String.prototype.fromHex = String.prototype.fromHex || function () {
        var len = this.length/2,
            ret = new Array(len);
        for (var i = 0; i < len; i++) {
            ret[i] = parseInt('0x' + this[2*i] + this[2*i+1]);
        return String.fromCharCode.apply(this,ret);
    };