ifPass()

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 subject will be passed back.

This function is valid in v2.7.0. This function has been downloaded 0 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:subject
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 subject 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 second argument) is passed back.