function hsCompileMany(patterns, defaultFlags, mode) {
  const dbPtrPtr = ref.alloc(r(hsDatabase));
  const errPtrPtr = ref.alloc(r(hsCompileError));

  const patternList = [];
  const flagList = [];
  const idList = [];

  defaultFlags = defaultFlags || (HS_FLAG_CASELESS | HS_FLAG_SOM_LEFTMOST);
  patterns.forEach((value, index) => {
    if (!value) throw new Error('Invalid pattern', value);
    if (typeof (value) === 'string') {
      patternList.push(value);
      flagList.push(defaultFlags);
    } else {
      if (!value.pattern || typeof (value.pattern) !== 'string') throw new Error('Invalid pattern', value.pattern);
      patternList.push(value.pattern);
      flagList.push(value.pattern || defaultFlags);
    }
    idList.push(index);
  });

  const res = hyperscan.hs_compile_multi(patternList, flagList, idList, patterns.length, mode || (HS_MODE_BLOCK), ref.NULL, dbPtrPtr, errPtrPtr);
  if (res !== 0) {
    const err = errPtrPtr.deref().deref();
    throw new Error(`Pattern compilation error: ${err.message} for pattern '${pattern}' with the ID ${err.expression}`);
  } else {
    return dbPtrPtr.deref();
  }
}
/**
 * Compile multiple patterns into a pattern database
 * @param {Array<{pattern: String, flags: int}>} patterns A list of strings or objects {pattern: String, flags: int} specifying the patterns and flags to use for each regex.
 * defaultFlags is used for each pattern that doesnt have a flag set explicitely.
 * @param {int} defaultFlags Flags (see HS_FLAG_...) to be used for patterns that do not explicitely overwrite the flags.
 * @param {int} mode Matching modes (see HS_MODE_...)
 */
Compile multiple patterns into a pattern database
@param {Array<{pattern: String, flags: int}>} patterns A list of strings or objects {pattern: String, flags: int} specifying the patterns and flags to use for each regex.
defaultFlags is used for each pattern that doesnt have a flag set explicitely.
@param {int} defaultFlags Flags  to be used for patterns that do not explicitely overwrite the flags.
@param {int} mode Matching modes
Compile multiple patterns into a pattern database @param { Array< { pattern : String flags : int } > } patterns A list of strings or objects { pattern : String flags : int } specifying the patterns and flags to use for each regex . defaultFlags is used for each pattern that doesnt have a flag set explicitely . @param { int } defaultFlags Flags to be used for patterns that do not explicitely overwrite the flags . @param { int } mode Matching modes
function hsCompileMany(patterns, defaultFlags, mode) {
  const dbPtrPtr = ref.alloc(r(hsDatabase));
  const errPtrPtr = ref.alloc(r(hsCompileError));
  const patternList = [];
  const flagList = [];
  const idList = [];
  defaultFlags = defaultFlags || (HS_FLAG_CASELESS | HS_FLAG_SOM_LEFTMOST);
  patterns.forEach((value, index) => {
    if (!value) throw new Error('Invalid pattern', value);
    if (typeof (value) === 'string') {
      patternList.push(value);
      flagList.push(defaultFlags);
    } else {
      if (!value.pattern || typeof (value.pattern) !== 'string') throw new Error('Invalid pattern', value.pattern);
      patternList.push(value.pattern);
      flagList.push(value.pattern || defaultFlags);
    }
    idList.push(index);
  });
  const res = hyperscan.hs_compile_multi(patternList, flagList, idList, patterns.length, mode || (HS_MODE_BLOCK), ref.NULL, dbPtrPtr, errPtrPtr);
  if (res !== 0) {
    const err = errPtrPtr.deref().deref();
    throw new Error(`Pattern compilation error: ${err.message} for pattern '${pattern}' with the ID ${err.expression}`);
  } else {
    return dbPtrPtr.deref();
  }
}
function hsCompileMany ( patterns , defaultFlags , mode ) { const dbPtrPtr = ref . alloc ( r ( hsDatabase ) ) ; const errPtrPtr = ref . alloc ( r ( hsCompileError ) ) ; const patternList = [ ] ; const flagList = [ ] ; const idList = [ ] ; defaultFlags = defaultFlags || ( HS_FLAG_CASELESS | HS_FLAG_SOM_LEFTMOST ) ; patterns . forEach ( ( value , index ) => { if ( ! value ) throw new Error ( 'Invalid pattern' , value ) ; if ( typeof ( value ) === 'string' ) { patternList . push ( value ) ; flagList . push ( defaultFlags ) ; } else { if ( ! value . pattern || typeof ( value . pattern ) !== 'string' ) throw new Error ( 'Invalid pattern' , value . pattern ) ; patternList . push ( value . pattern ) ; flagList . push ( value . pattern || defaultFlags ) ; } idList . push ( index ) ; } ) ; const res = hyperscan . hs_compile_multi ( patternList , flagList , idList , patterns . length , mode || ( HS_MODE_BLOCK ) , ref . NULL , dbPtrPtr , errPtrPtr ) ; if ( res !== 0 ) { const err = errPtrPtr . deref ( ) . deref ( ) ; throw new Error ( ` ${ err . message } ${ pattern } ${ err . expression } ` ) ; } else { return dbPtrPtr . deref ( ) ; } }
Compile multiple patterns into a pattern database
 @param {Array<{pattern: String, flags: int}>} patterns A list of strings or objects {pattern: String, flags: int} specifying the patterns and flags to use for each regex.
Compile multiple patterns into a pattern database @param { Array< { pattern : String flags : int } > } patterns A list of strings or objects { pattern : String flags : int } specifying the patterns and flags to use for each regex .