linq.js
function first(predicate) {
  predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate;

  let error = new Error('No element satisfies the condition in predicate.');
  let firstElement = firstOrDefault.apply(this, [predicate, error]);
  if (firstElement === error) throw error;

  return firstElement;
}
function first(predicate) {
  predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate;

  let error = new Error('No element satisfies the condition in predicate.');
  let firstElement = firstOrDefault.apply(this, [predicate, error]);
  if (firstElement === error) throw error;

  return firstElement;
}
function first ( predicate ) { predicate = typeof predicate === 'function' ? predicate : util . defaultPredicate ; let error = new Error ( 'No element satisfies the condition in predicate.' ) ; let firstElement = firstOrDefault . apply ( this , [ predicate , error ] ) ; if ( firstElement === error ) throw error ; return firstElement ; }
Returns the first element in a sequence that satisfies a specified condition or throws an error if not found.

@param {(Function)} predicate The function called per iteraction till returns true.
@param defaultValue The default value.
@return The first element which satisfy condition or default value.
Returns the first element in a sequence that satisfies a specified condition or throws an error if not found .