email validation loop

Benchmark created on


Setup

function isValidEmail(value) {
  return (
    typeof value == 'string' &&
    value.length >= 6 &&
    value.length <= 254 &&
    /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(value)
  );
}

var emails = [
  'my@example.com',
  'invalid@@email',
  'ok@localhost'
];

Test runner

Ready to run.

Testing in
TestOps/sec
filter valid emails
emails.filter(isValidEmail);
ready
repeat test
emails.filter(isValidEmail);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.