Skip to content

nonefn

Summary

True if no predicates passed when applied to arguments.

Description

Takes one or more predicates and returns a function that takes any number of arguments and returns true if no predicates returned logical true when applied to these arguments. Returns false if one did.

Examples

Make sure that both x and y are neither numbers or strings.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
const is_num = x => typeof x == 'number';
const is_str = x => typeof x == 'string';

const no_num_or_str = nonefn( (x, _) => is_num(x) || is_str(x)
                            , (_, y) => is_str(y) || is_str(y));

no_num_or_str(    40,      2); //=> false
no_num_or_str(  '21',   '21'); //=> false
no_num_or_str(  '40',      2); //=> false
no_num_or_str(['40'], {x: 2}); //=> true

Parameters

Name Type Description
pred function One or more predicates

Return

function