/* eslint no-bitwise:0 
This function is run only once to initialize the table
@returns {Array}
345728
function makeCRCTable() {
    var c;
    var crcTable = [];
    for (var n = 0; n < 256; n++) {
        c = n;
        for (var k = 0; k < 8; k++) {
            /* jslint bitwise: true */
            c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
        }
        crcTable[n] = c;
    }
    return crcTable;
}
1220708
function AES_Init() {
	AES_Sbox_Inv = new Array(256);
	for(var i = 0; i < 256; i++)
		AES_Sbox_Inv[AES_Sbox[i]] = i;

	AES_ShiftRowTab_Inv = new Array(16);
	for(var i = 0; i < 16; i++)
		AES_ShiftRowTab_Inv[AES_ShiftRowTab[i]] = i;

	AES_xtime = new Array(256);
	for(var i = 0; i < 128; i++) {
		AES_xtime[i] = i << 1;
		AES_xtime[128 + i] = (i << 1) ^ 0x1b;
	}
}
1048932
function _makeBitReversalTable() {
    var i = 0,
        j = 0,
        k = 0;
    _bitrev[0] = 0;
    while (++i < _n) {
        k = _n >> 1;
        while (k <= j) {
            j -= k;
            k >>= 1;
        }
        j += k;
        _bitrev[i] = j;
    }
}
1026934
function () {
            var selectedIndexes = this.getSelectedIndexes();
            var retVal = [];
            var items = this._data.items;
            for (var i = 0, length = selectedIndexes.length; i < length; i++) {
                retVal[i] = items[selectedIndexes[i]];
            }
            return retVal;
        }
270283
function() {
            	var v = [];
            	
            	for(var i = 1; i <= this.cols(); i++) {
            	    for(var j = 1; j <= this.rows(); j++) {
            		v.push(this.e(j, i));
            	    }
            	}

            	return $V(v);
                }
1197926
function createTables() {
  return bluebird.all(getComponents().map(component => client.createTable(`components.${component}`)))
    .then(() => bluebird.all(getLayouts().map(layout => client.createTableWithMeta(`layouts.${layout}`))))
    .then(() => client.createTableWithMeta('pages'))
    .then(() => client.raw('CREATE TABLE IF NOT EXISTS ?? ( id TEXT PRIMARY KEY NOT NULL, data TEXT NOT NULL, url TEXT );', ['uris']))
    .then(() => createRemainingTables());
}
570542
function tableHead () {
  var args = arrayify(arguments)
  var data = args.shift()
  if (!data) return
  args.pop()
  var cols = args
  var colHeaders = cols.map(function (col) {
    var spl = col.split('|')
    return spl[1] || spl[0]
  })
  cols = cols.map(function (col) {
    return col.split('|')[0]
  })
  var toSplice = []
  cols = cols.filter(function (col, index) {
    var hasValue = data.some(function (row) {
      return typeof row[col] !== 'undefined'
    })
    if (!hasValue) toSplice.push(index)
    return hasValue
  })
  toSplice.reverse().forEach(function (index) {
    colHeaders.splice(index, 1)
  })

  var table = '| ' + colHeaders.join(' | ') + ' |\n'
  table += cols.reduce(function (p) { return p + ' --- |' }, '|') + '\n'
  return table
}
183343
function _buildTable() {
        if (!count($this->_data)) {
            return '';
        }

        $vertical = $this->_border['vertical'];
        $separator = $this->_getSeparator();

        $return = array();
        for ($i = 0; $i < count($this->_data); $i++) {
            for ($j = 0; $j < count($this->_data[$i]); $j++) {
                if ($this->_data[$i] !== self::CONSOLE_TABLE_HORIZONTAL_RULE &&
                    $this->_strlen($this->_data[$i][$j]) <
                    $this->_cell_lengths[$j]
                ) {
                    $this->_data[$i][$j] = $this->_strpad($this->_data[$i][$j],
                        $this->_cell_lengths[$j],
                        ' ',
                        $this->_col_align[$j]);
                }
            }

            if ($this->_data[$i] !== self::CONSOLE_TABLE_HORIZONTAL_RULE) {
                $row_begin = $this->_borderVisibility['left']
                    ? $vertical . str_repeat(' ', $this->_padding)
                    : '';
                $row_end = $this->_borderVisibility['right']
                    ? str_repeat(' ', $this->_padding) . $vertical
                    : '';
                $implode_char = str_repeat(' ', $this->_padding) . $vertical
                    . str_repeat(' ', $this->_padding);
                $return[] = $row_begin
                    . implode($implode_char, $this->_data[$i]) . $row_end;
            } elseif (!empty($separator)) {
                $return[] = $separator;
            }

        }

        $return = implode(PHP_EOL, $return);
        if (!empty($separator)) {
            if ($this->_borderVisibility['inner']) {
                $return = $separator . PHP_EOL . $return;
            }
            if ($this->_borderVisibility['bottom']) {
                $return .= PHP_EOL . $separator;
            }
        }
        $return .= PHP_EOL;

        if (!empty($this->_headers)) {
            $return = $this->_getHeaderLine() . PHP_EOL . $return;
        }

        return $return;
    }
1353881
function _fnCoordsFromCell( n )
	{
		if ( _oDatatable )
		{
			return [
				$('td', n.parentNode).index(n),
				$('tr', n.parentNode.parentNode).index(n.parentNode) + _oDatatable._iDisplayStart
			];
		}
		else
		{
			return [
				$('td', n.parentNode).index(n),
				$('tr', n.parentNode.parentNode).index(n.parentNode)
			];
		}
	}
464144
function tableFromMethods(methodsArr) {
  const headers = ["Method Name", "Type", "Parameters", "Description"]
  let rows = []

  // construct rows of table array of methods
  methodsArr.forEach((method) => {
    let cols = []

    cols.push(method["name"]) // method name
    let paramList = ''
    method["params"].forEach((param) => {
      paramList += `${param["name"]}: ${param["type"]["name"]} - ${param["description"]}\n`
    })
    cols.push(paramList) // list of method parameters
    cols.push(`${method["description"]}`) // description of the method

    rows.push(cols);
  })
  
  return rows.length > 0 ? {table: {headers, rows}} : null
}
1354099
function HuffmanTable(table) {
  function createTree(codes, position) {
    if (codes.length === 1) {
      return [table.indexOf(codes[0])];
    }

    else {
      position = position || 0;
      var zero = [];
      var one = [];
      for (var i = 0; i < codes.length; i++) {
        var string = codes[i];
        if (string[position] === '0') {
          zero.push(string);
        } else {
          one.push(string);
        }
      }
      return [createTree(zero, position + 1), createTree(one, position + 1)];
    }
  }

  this.tree = createTree(table);

  this.codes = table.map(function(bits) {
    return parseInt(bits, 2);
  });
  this.lengths = table.map(function(bits) {
    return bits.length;
  });
}
909539
function initDataSourceVariable() {
    this.selectRows = new Array();
    this.selectRowsObj = new Array();
    this.selectRowsIndex = new Array();
    this.allRows = new Array();
    this.eidtRowIndex = -1; // 当前修改行
}
792426
function() {

    var _buffer = new Array();
    var _length = 0;

    var _this = {};

    _this.getBuffer = function() {
	return _buffer;
    };

    _this.getAt = function(index) {
	var bufIndex = Math.floor(index / 8);
	return ( (_buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1;
    };

    _this.put = function(num, length) {
	for (var i = 0; i < length; i += 1) {
	    _this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1);
	}
    };

    _this.getLengthInBits = function() {
	return _length;
    };

    _this.putBit = function(bit) {

	var bufIndex = Math.floor(_length / 8);
	if (_buffer.length <= bufIndex) {
	    _buffer.push(0);
	}

	if (bit) {
	    _buffer[bufIndex] |= (0x80 >>> (_length % 8) );
	}

	_length += 1;
    };

    return _this;
}
604683
function _initArray() {
    if (typeof Uint32Array !== 'undefined') {
        _bitrev = new Uint32Array(_n);
    } else {
        _bitrev = [];
    }
    if (typeof Float64Array !== 'undefined') {
        _cstb = new Float64Array(_n * 1.25);
    } else {
        _cstb = [];
    }
}
1285473
function initializeDB() {
  db = new loki('perftest');

  var start, end, totalTime;
  var totalTimes = [];
  var totalMS = 0.0;

  samplecoll = db.addCollection('samplecoll');
  /*
    {
      asyncListeners: true,
      disableChangesApi: true,
      transactional: false,
      clone: false 
    }
  ); 
  */

  for (var idx = 0; idx < arraySize; idx++) {
    var v1 = genRandomVal();
    var v2 = genRandomVal();

    start = process.hrtime();
    samplecoll.insert({
      customId: idx,
      val: v1,
      val2: v2,
      val3: "more data 1234567890"
    });
    end = process.hrtime(start);
    totalTimes.push(end);
  }

  for (var idx = 0; idx < totalTimes.length; idx++) {
    totalMS += totalTimes[idx][0] * 1e3 + totalTimes[idx][1] / 1e6;
  }


  //var totalMS = end[0] * 1e3 + end[1]/1e6;
  totalMS = totalMS.toFixed(2);
  var rate = arraySize * 1000 / totalMS;
  rate = rate.toFixed(2);
  console.log("load (insert) : " + totalMS + "ms (" + rate + ") ops/s");
}
1187171
function Environment() {

    var environment = {};

    var names = [];
    var values = [];

    var t = {};

    t.getNames = getNames;
    t.getValues = getValues;
    t.add = add;
    t.clear = clear;

    return t;

    function getNames() {

        return names;

    }

    function getValues() {

        return values;

    }

    function add(value) {

        // Separates environment into two arrays: names and values to the following initialization of Function object.
        if (value) {

            lodash.assign(environment, value);

            names = lodash.keys(environment);
			// TODO ES-2017 - > values = Object.values(environment);
			values = lodash.keys(environment).map(function(k) { return environment[k]});

        }

    }

    function clear() {

        environment = {};

        names = [];
        values = [];

    }

}
731398
function tableFromSlots(slotsObj) {
  const headers = ["Slot", "Description"]
  let rows = []

  for(const slot in slotsObj) {
    let cols = []
    cols.push(`${slot}`) // name of the slot
    cols.push(`${slotsObj[slot]["description"] || ''}`) // description of the slot

    rows.push(cols)
  }

  return rows.length > 0 ? {table: {headers, rows}} : null
}