npm.io
1.0.1 • Published 7 years ago

@sharyn/util.either

Licence
MIT
Version
1.0.1
Deps
1
Size
2 kB
Vulns
0
Weekly
0
Stars
29

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