1.0.1 • Published 5 years ago

@sharyn/util.either v1.0.1

Weekly downloads
8
License
MIT
Repository
github
Last release
5 years ago

🌹 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