Blame view

node_modules/hpack.js/lib/hpack/utils.js 511 Bytes
aaac7fed   liuqimichale   add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  exports.assert = function assert(cond, text) {
    if (!cond)
      throw new Error(text);
  };
  
  exports.stringify = function stringify(arr) {
    var res = '';
    for (var i = 0; i < arr.length; i++)
      res += String.fromCharCode(arr[i]);
    return res;
  };
  
  exports.toArray = function toArray(str) {
    var res = [];
    for (var i = 0; i < str.length; i++) {
      var c = str.charCodeAt(i);
      var hi = c >>> 8;
      var lo = c & 0xff;
      if (hi)
        res.push(hi, lo);
      else
        res.push(lo);
    }
    return res;
  };