function hsScan(db, data, callback, scratch, context) {
  scratch = scratch || hsAllocScratch(db);
  let matchFound = false;
  const res = hyperscan.hs_scan(db, data, Buffer.byteLength(data), 0, scratch, hsMatchEventHandler((id, fromIdx, toIdx, flags, contextPtr) => {
    // console.log(`Match found! id: ${id}, from: ${fromIdx}, to: ${toIdx}, flags: ${flags}, context: ${contextPtr}`)
    // console.log(contextPtr);
    matchFound = true;
    callback(id, fromIdx, toIdx, flags, contextPtr);
    return 0;
  }), context);
  console.log(`hs_scan result: ${res}`);
  if (!matchFound) callback(null);
}
/**
 * Scans a string for matches. Calls the specified match event handler once a match is found. If no matches are found, the callback is called once with a single argument 'null'
 * @param {hsDatabase} db The database to use
 * @param {String} data The string to scan
 * @param {matchEventHandler} callback The callback to run when a match is found
 * @param {hsScratch} scratch A scratch to use for matching
 * @param {*} context
 */
Scans a string for matches. Calls the specified match event handler once a match is found.
Scans a string for matches . Calls the specified match event handler once a match is found .
function hsScan(db, data, callback, scratch, context) {
  scratch = scratch || hsAllocScratch(db);
  let matchFound = false;
  const res = hyperscan.hs_scan(db, data, Buffer.byteLength(data), 0, scratch, hsMatchEventHandler((id, fromIdx, toIdx, flags, contextPtr) => {
    matchFound = true;
    callback(id, fromIdx, toIdx, flags, contextPtr);
    return 0;
  }), context);
  console.log(`hs_scan result: ${res}`);
  if (!matchFound) callback(null);
}
function hsScan ( db , data , callback , scratch , context ) { scratch = scratch || hsAllocScratch ( db ) ; let matchFound = false ; const res = hyperscan . hs_scan ( db , data , Buffer . byteLength ( data ) , 0 , scratch , hsMatchEventHandler ( ( id , fromIdx , toIdx , flags , contextPtr ) => { matchFound = true ; callback ( id , fromIdx , toIdx , flags , contextPtr ) ; return 0 ; } ) , context ) ; console . log ( ` ${ res } ` ) ; if ( ! matchFound ) callback ( null ) ; }
Scans a string for matches.
Scans a string for matches .
// console.log(`Match found! id: ${id}, from: ${fromIdx}, to: ${toIdx}, flags: ${flags}, context: ${contextPtr}`) // console.log(contextPtr);