pick-of
v0.0.1
Published
Utilitary library containing methods for testings collections
Downloads
0
Readme
pick-of
Simple
allOf
,oneOf
andmixOf
methods.
Utilitary library containing methods for testings collections.
Install
$ yarn add allone
Usage
Importing
import { oneOf, allOf, mixOf } from 'allone'
oneOf
oneOf
accepts an array of options and returns an object with a test
function that returns true
if at least one of options are present in the input.
const one = oneOf(1, 2, 3)
one.test
will return true input contains 1
, 2
OR 3
.
valid.test([1]) // true
valid.test([1, 8, 63]) // true
valid.test([4, 5, 6]) // false
valid.test([-1, 0, 4, 5]) // false
allOf
allOf
accepts an array of requirements and returns an object with a test
function that returns true
if all requirements are present in the input.
const all = allOf(1, 2, 3)
all.test
will return true if the input contains 1
, 2
AND 3
.
all.test([1]) // false
all.test([1, 2, 3]) // true
all.test([1, 2, 3, 4]) // true
mixOf
mixOf
accepts an array of testables as arguments and returns an object with a test
function that returns true
if all testables are true.
const mix = mixOf(
oneOf(1),
allOf(4, 5, 6)
)
mix.test
will return true for any input that contains 1
and contains 4
, 5
and 6
.