function findLastIndex(source, pat) {
  const e = pat[pat.length - 1];
  for (let i = source.length - 1; i >= 0; i--) {
    if (source[i] !== e) continue;
    const pin = i;
    let matched = 1;
    let j = i;
    while (matched < pat.length) {
      j--;
      if (source[j] !== pat[pat.length - 1 - (pin - j)]) {
        break;
      }
      matched++;
    }
    if (matched === pat.length) {
      return pin - pat.length + 1;
    }
  }
  return -1;
}
/** Find last index of binary pattern from a. If not found, then return -1.
 * @param source source array
 * @param pat pattern to find in source array
 */
Find last index of binary pattern from a. If not found, then return -1.
@param source source array
@param pat pattern to find in source array
Find last index of binary pattern from a . If not found then return - 1 . @param source source array @param pat pattern to find in source array
function findLastIndex(source, pat) {
  const e = pat[pat.length - 1];
  for (let i = source.length - 1; i >= 0; i--) {
    if (source[i] !== e) continue;
    const pin = i;
    let matched = 1;
    let j = i;
    while (matched < pat.length) {
      j--;
      if (source[j] !== pat[pat.length - 1 - (pin - j)]) {
        break;
      }
      matched++;
    }
    if (matched === pat.length) {
      return pin - pat.length + 1;
    }
  }
  return -1;
}
function findLastIndex ( source , pat ) { const e = pat [ pat . length - 1 ] ; for ( let i = source . length - 1 ; i >= 0 ; i -- ) { if ( source [ i ] !== e ) continue ; const pin = i ; let matched = 1 ; let j = i ; while ( matched < pat . length ) { j -- ; if ( source [ j ] !== pat [ pat . length - 1 - ( pin - j ) ] ) { break ; } matched ++ ; } if ( matched === pat . length ) { return pin - pat . length + 1 ; } } return - 1 ; }
Find last index of binary pattern from a.
Find last index of binary pattern from a .