ifPasses()

Tests subject against control and if it results in a true-ish value truthyValue will be passed back. Otherwise, if opt_falsyValue is given it will be passed back, but if not control will be passed back.

This function is valid in v2.13.0 to v2.14.0. This function has been downloaded 25 times.

Parameters

{Function|RegExp} control
If this is a function it will be called with subject being the only argument. Otherwise, this regular expression will be tested against subject.
{*} subject
Value to test
{*} truthyValue
Value to be returned if testing subject against control results in a true-ish value.
{*=} opt_falsyValue Optional, Default:control
Value to be returned if testing subject against control results in a false-ish value.

Returns

{*}
truthyValue will be returned if testing subject against control results in a true-ish value. Otherwise, if opt_falsyValue is given it will be returned, but if not given control will be returned.

Required Function

This function requires the following function which is included automatically:

  • ifIs()
    If the first and second arguments are the same the third argument is passed back, otherwise the fourth argument (or if not given the first argument) is passed back.