Skip to content

Utilitary library containing methods for testings collections

Notifications You must be signed in to change notification settings

Ascenio/pick-of

 
 

Repository files navigation

pick-of

codecov

Simple allOf, oneOf and mixOf methods.

Utilitary library containing methods for testings collections.

Install

$ yarn add pick-of

Usage

Importing

import { oneOf, allOf, mixOf } from 'pick-of'

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.


Made with ❤ by Jota.

About

Utilitary library containing methods for testings collections

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 96.4%
  • Shell 2.0%
  • JavaScript 1.6%