Predicate function.
Predicate callback function.
Predicate callback function.
Predicate callback function.
Predicate callback function.
Function invoked after condition check.
If a predicate function returns a truthy value, invokes x
; otherwise, invokes y
.
predicate function
function to invoke if a condition is truthy
function to invoke if a condition is falsy
callback to invoke upon completion
var randu = require( `@stdlib/random/base/randu` );
function predicate( clbk ) {
setTimeout( onTimeout, 0 );
function onTimeout() {
clbk( null, randu() > 0.5 );
}
}
function x( clbk ) {
setTimeout( onTimeout, 0 );
function onTimeout() {
clbk( null, 1.0 );
}
}
function y( clbk ) {
setTimeout( onTimeout, 0 );
function onTimeout() {
clbk( null, -1.0 );
}
}
function done( error, result ) {
if ( error ) {
throw error;
}
console.log( result );
}
ifthenAsync( predicate, x, y, done );
Callback function.
encountered error or null
results