title: Nodejs code to convert hex string to byte array?
body: <p>Can anyone please tell me equivalent <code>Nodejs</code> code to convert hex string to byte array which is in <code>Java</code></p>
  
  <pre><code>public static byte[] hexStringToByteArray(String s) {
      byte[] b = new byte[s.length() / 2];
      for (int i = 0; i &lt; b.length; i++) {
          int index = i * 2;
          int v = Integer.parseInt(s.substring(index, index + 2), 16);
          b[i] = (byte) v;
  
      }
      return b;
  }
  </code></pre>