docs/01_drawrect/index.js
// 'sig' parameter is required if the function being added is a JS function.
'sig' parameter is required if the function being added is a JS function.
' sig ' parameter is required if the function being added is a JS function .
function addFunction(func, sig) {
  assert(typeof func !== 'undefined');
  if (!functionsInTableMap) {
    functionsInTableMap = new WeakMap();
    updateTableMap(0, wasmTable.length);
  }
  if (functionsInTableMap.has(func)) {
    return functionsInTableMap.get(func);
  }
  var ret = getEmptyTableSlot();
  try {
    setWasmTableEntry(ret, func);
  } catch (err) {
    if (!(err instanceof TypeError)) {
      throw err;
    }
    assert(typeof sig !== 'undefined', 'Missing signature argument to addFunction: ' + func);
    var wrapped = convertJsFunctionToWasm(func, sig);
    setWasmTableEntry(ret, wrapped);
  }
  functionsInTableMap.set(func, ret);
  return ret;
}
function addFunction ( func , sig ) { assert ( typeof func !== 'undefined' ) ; if ( ! functionsInTableMap ) { functionsInTableMap = new WeakMap ( ) ; updateTableMap ( 0 , wasmTable . length ) ; } if ( functionsInTableMap . has ( func ) ) { return functionsInTableMap . get ( func ) ; } var ret = getEmptyTableSlot ( ) ; try { setWasmTableEntry ( ret , func ) ; } catch ( err ) { if ( ! ( err instanceof TypeError ) ) { throw err ; } assert ( typeof sig !== 'undefined' , 'Missing signature argument to addFunction: ' + func ) ; var wrapped = convertJsFunctionToWasm ( func , sig ) ; setWasmTableEntry ( ret , wrapped ) ; } functionsInTableMap . set ( func , ret ) ; return ret ; }
'sig' parameter is required if the function being added is a JS function.
' sig ' parameter is required if the function being added is a JS function .
// Check if the function is already in the table, to ensure each function // gets a unique index. First, create the map if this is the first use. // It's not in the table, add it now. // Set the new value. // Attempting to call this with JS function will cause of table.set() to fail