@sharyn/util.either

either returns true if the first argument equals any of the other arguments.

Usage no npm install needed!

<script type="module">
  import sharynUtilEither from 'https://cdn.skypack.dev/@sharyn/util.either';
</script>

README

🌹 either

either returns true if the first argument equals any of the other arguments.

Basically, you can replace this:

if (something === 'foo' || something === 'bar' || something === 'baz')
// or
if (['foo', 'bar', 'baz'].includes(something))

By this:

import either from '@sharyn/util/either'
// or import { either } from '@sharyn/util'

if (either(something, 'foo', 'bar', 'baz'))

either uses deep equality so you can test objects as well:

either(obj, { a: 1 }, { a: 2 })

either is part of @sharyn/util